<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>LightSaber</title><link href="http://haginara.github.io/" rel="alternate"></link><link href="http://haginara.github.io/feeds/all.atom.xml" rel="self"></link><id>http://haginara.github.io/</id><updated>2016-08-04T00:00:00-07:00</updated><entry><title>Python-ldap on OS X</title><link href="http://haginara.github.io/posts/2016/08/python-ldap-on-os-x/" rel="alternate"></link><published>2016-08-04T00:00:00-07:00</published><updated>2016-08-04T00:00:00-07:00</updated><author><name>haginara</name></author><id>tag:haginara.github.io,2016-08-04:/posts/2016/08/python-ldap-on-os-x/</id><summary type="html">&lt;p&gt;Simple guide to install python-ldap on os x&lt;/p&gt;</summary><content type="html">&lt;p&gt;python-ldap is supporting the Python2 and Python3. But I never tried to install on OS X.&lt;/p&gt;
&lt;p&gt;I got error message, when I try to install the python-ldap via pip&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;pip&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt; &lt;span class="n"&gt;python&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;ldap&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="n"&gt;Modules&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;LDAPObject&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;fatal&lt;/span&gt; &lt;span class="k"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="c"&gt;&amp;#39;sasl.h&amp;#39; file not found&lt;/span&gt;
&lt;span class="p"&gt;#&lt;/span&gt;&lt;span class="n"&gt;include&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;sasl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
         &lt;span class="o"&gt;^&lt;/span&gt;
&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;error&lt;/span&gt; &lt;span class="n"&gt;generated&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;span class="k"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;command&lt;/span&gt; &lt;span class="c"&gt;&amp;#39;cc&amp;#39; failed with exit status 1&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;The official python-ldap site(https://www.python-ldap.org/download.html) is having the guide to install on OS X&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;Set up a suitable development environment by running xcode-select --install. After that you can install directly from PyPI.
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;xcode-select  --install
xcode-select: note: install requested for command line developer tools
sudo pip install python-ldap
Password:
Collecting python-ldap
  Downloading python-ldap-2.4.27.tar.gz (125kB)
    100% |████████████████████████████████| 133kB 175kB/s
Requirement already satisfied (use --upgrade to upgrade): setuptools in /Library/Python/2.7/site-packages (from python-ldap)
Installing collected packages: python-ldap
  Running setup.py install for python-ldap ... done
Successfully installed python-ldap-2.4.27
python -c "import ldap; print(ldap)"
&lt;module 'ldap' from '/Library/Python/2.7/site-packages/ldap/__init__.pyc'&gt;
```&lt;/p&gt;</content><category term="osx"></category><category term="ldap"></category><category term="python"></category></entry><entry><title>Removing the BOM characters using python</title><link href="http://haginara.github.io/posts/2016/07/removing-the-bom-characters-using-python/" rel="alternate"></link><published>2016-07-21T16:03:00-07:00</published><updated>2016-07-21T16:03:00-07:00</updated><author><name>haginara</name></author><id>tag:haginara.github.io,2016-07-21:/posts/2016/07/removing-the-bom-characters-using-python/</id><summary type="html">&lt;p&gt;Removing the BOM characters using python&lt;/p&gt;</summary><content type="html">&lt;p&gt;I exported the one of the csv file I wan to get some information using csvkit.
but csvkit return the error like below:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&amp;#39;cp949&amp;#39; codec can&amp;#39;t encode character u&amp;#39;\ufeff&amp;#39; in position 5: illegal multibyte sequence
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;BOM(https://en.wikipedia.org/wiki/Byte_order_mark) characters in the exported files. and I wrote the script to remove the BOM characters&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;codecs&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;sys&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;os&lt;/span&gt;

&lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;%s&lt;/span&gt;&lt;span class="s2"&gt;.new&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;w&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;r&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;new&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;unicode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;codecs&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;BOM_UTF8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;utf-8&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rename&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;%s&lt;/span&gt;&lt;span class="s2"&gt;.bak&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
    &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rename&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;%s&lt;/span&gt;&lt;span class="s2"&gt;.new&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="ne"&gt;Exception&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;</content><category term="python"></category><category term="utf8"></category></entry><entry><title>How to make a Simple .deb file</title><link href="http://haginara.github.io/posts/2016/07/how-to-make-a-simple-deb-file/" rel="alternate"></link><published>2016-07-06T12:09:00-07:00</published><updated>2016-07-06T12:09:00-07:00</updated><author><name>haginara</name></author><id>tag:haginara.github.io,2016-07-06:/posts/2016/07/how-to-make-a-simple-deb-file/</id><summary type="html">&lt;p&gt;How to make a Simple .deb file&lt;/p&gt;</summary><content type="html">&lt;h4&gt;References&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;http://packaging.ubuntu.com/html/packaging-new-software.html&lt;/li&gt;
&lt;li&gt;http://packaging.ubuntu.com/html/debian-dir-overview.html&lt;/li&gt;
&lt;li&gt;http://tldp.org/HOWTO/html_single/Debian-Binary-Package-Building-HOWTO/#AEN66&lt;/li&gt;
&lt;li&gt;https://raphaelhertzog.com/2010/12/17/do-not-build-a-debian-package-with-dpkg-b/&lt;/li&gt;
&lt;li&gt;https://raphaelhertzog.com/debian-packaging/&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Standard debian notation is all lowercase in the following format&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&amp;lt;project&amp;gt;_&amp;lt;major_version&amp;gt;.&amp;lt;minor_version&amp;gt;-&amp;lt;package revision&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;p&gt;helloworld_1.0-1&lt;/p&gt;
&lt;h4&gt;Step by Step&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;create a directory to make my package in. the name should be same as the package name
&lt;code&gt;mkdir helloword_1.0-1&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Pretend that the packaging directory is actually that root of the file system. Put the files of your program where they would be installed to on a system.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;mkdir helloworld_1.0-1/user
mkdir helloworld_1.0-1/user/local
mkdir helloworld_1.0-1/user/local/bin
cp &amp;quot;~/Projects/Hello World/helloworld&amp;quot; helloworld_1.0-1/usr/local/bin
&lt;/pre&gt;&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Create a special metadata file with which the package manager will install your program&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;mkdir helloword_1.0-1/DEBIAN
touch helloword_1.0-1/DEBIAN/control
Put something like this in that file
Package: helloworld
Version: 1.0-1
Section: base
Priority: optional
Architecture: i386
Depends: libsomethingorrather (&amp;gt;= 1.2.13), anotherDependency (&amp;gt;= 1.2.6)
Maintainer: Your Name &amp;lt;you@email.com&amp;gt;
Description: Hello World
 When you need some sunshine, just run this
 small program!

 (the space before each line in the description is important)
&lt;/pre&gt;&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;You just need to make the package&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;dpkg-deb --build helloworld_1.0-1
&lt;/pre&gt;&lt;/div&gt;</content><category term="deb"></category><category term="ubuntu"></category></entry><entry><title>Install Asus PCE-N53 Driver for Ubuntu 14.04</title><link href="http://haginara.github.io/posts/2016/07/install-asus-pce--n53-driver-for-ubuntu-14.04/" rel="alternate"></link><published>2016-07-05T00:00:00-07:00</published><updated>2016-07-05T00:00:00-07:00</updated><author><name>haginara</name></author><id>tag:haginara.github.io,2016-07-05:/posts/2016/07/install-asus-pce--n53-driver-for-ubuntu-14.04/</id><summary type="html"></summary><content type="html">&lt;p&gt;When I bought the asus wireless NIC, My dekstop was using the Windows.
but recently I changed to Ubuntu 14.04 Dekstop. The hell of the WIRELESS was started from that time.&lt;/p&gt;
&lt;p&gt;The driver which provided by Asus is not supported to Kernel 3.x version. I found the patched version from the github.com&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/unused/patched-Asus-PCE-N53-linux-driver" title="https://github.com/unused/patched-Asus-PCE-N53-linux-driver"&gt;https://github.com/unused/patched-Asus-PCE-N53-linux-driver&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Download the files, and run command.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;sudo make &amp;amp;&amp;amp; sudo make instal&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;This commands are only accepted to current session. After reboot the computer, you will have to enabled the driver again.&lt;/p&gt;
&lt;p&gt;Add the &lt;strong&gt;ifconfig ra0 up&lt;/strong&gt; to the &lt;strong&gt;/etc/rc.local&lt;/strong&gt; and add &lt;strong&gt;rt5592sta&lt;/strong&gt; to the &lt;strong&gt;/etc/modules&lt;/strong&gt;&lt;/p&gt;</content><category term="ubuntu"></category><category term="pce-n53"></category><category term="asus"></category><category term="wlan"></category></entry><entry><title>Suricata IDS on Ubuntu Server</title><link href="http://haginara.github.io/posts/2016/07/suricata-ids-on-ubuntu-server/" rel="alternate"></link><published>2016-07-05T00:00:00-07:00</published><updated>2016-07-05T00:00:00-07:00</updated><author><name>haginara</name></author><id>tag:haginara.github.io,2016-07-05:/posts/2016/07/suricata-ids-on-ubuntu-server/</id><summary type="html">&lt;p&gt;how to install the suricata on Ubuntu server&lt;/p&gt;</summary><content type="html">&lt;h3&gt;TOC&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Suricata 설치하기&lt;/li&gt;
&lt;li&gt;Suricata 관리하기&lt;/li&gt;
&lt;li&gt;ELK 로 Suricata 로그 관리&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Suricata 설치하기&lt;/h3&gt;
&lt;h4&gt;suricata repository 종류&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Stable&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;sudo add-apt-repository ppa:oisf/suricata-stable
sudo apt-get update &amp;amp;&amp;amp; sudo apt-get install suricata
&lt;/pre&gt;&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Beta&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;sudo add-apt-repository ppa:oisf/suricata-beta
sudo apt-get update &amp;amp;&amp;amp; sudo apt-get install suricata
&lt;/pre&gt;&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Daily Release&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;sudo add-apt-repository ppa:oisf/suricata-daily
sudo apt-get update &amp;amp;&amp;amp; sudo apt-get install suricata
&lt;/pre&gt;&lt;/div&gt;


&lt;h4&gt;Interface card 설정 하기&lt;/h4&gt;
&lt;p&gt;Network interface file&lt;/p&gt;
&lt;p&gt;&lt;code&gt;sudo vim /etc/network/interfaces&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;아래 내용을 추가한다.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;auto eth1
iface eth1 inet manual
up ifconfig $IFACE 0.0.0.0 up
up ip link set $IFACE promisc on
down ip link set $IFACE promisc off
down ifconfig $IFACE down
&lt;/pre&gt;&lt;/div&gt;


&lt;h4&gt;로그 종류&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;eve.json&lt;/li&gt;
&lt;li&gt;fast.log&lt;/li&gt;
&lt;li&gt;http.log&lt;/li&gt;
&lt;li&gt;stats.log&lt;/li&gt;
&lt;li&gt;unified2.alert.1437460553&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Suricata 관리하기&lt;/h3&gt;
&lt;h4&gt;oinkmaster&lt;/h4&gt;
&lt;h4&gt;pulledpork&lt;/h4&gt;
&lt;h4&gt;py-idstools&lt;/h4&gt;
&lt;p&gt;Sample Command&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;sudo idstools-rulecat --rules-dir /etc/suricata/rules/ --sid-msg-map /etc/suricata/rules/sid-msg.map --disable disable.conf --post-hook &lt;span class="s2"&gt;&amp;quot;/etc/init.d/suricata restart&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;h5&gt;인자 설명&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;rules-dir : 룰 폴더의 경로&lt;/li&gt;
&lt;li&gt;sid-msg-map: sid-msg.map 파일의 경로&lt;/li&gt;
&lt;li&gt;disable: 사용하지 않을 룰의 sid를 가지고 있는 파일  &lt;/li&gt;
&lt;li&gt;disable 파일의 경우 &lt;strong&gt;룰번호/n&lt;/strong&gt; 형태로 파일을 작성 할 수 있다.&lt;/li&gt;
&lt;li&gt;post-hook: 룰이 변경됬을 경우 실행할 명렁&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;해당 명령은 &lt;strong&gt;cronjob&lt;/strong&gt;에 추가 할수 있다.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;sudo vim /etc/cron.hourly/rulecat.hourly
### Adding the command to rulecat.houly file
#!/bin/bash

/usr/local/bin/idstools-rulecat  --rules-dir /etc/suricata/rules/ --sid-msg-map /etc/suricata/rules/sid-msg.map --disable disable.conf --post-hook &amp;quot;/etc/init.d/suricata restart&amp;quot;

### Adding the execution permission to this file
sudo chmod 755 /etc/cron.hourly/rulecat.hourly
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Result&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;Last download less than &lt;span class="m"&gt;15&lt;/span&gt; minutes ago. Not fetching.
Loaded &lt;span class="m"&gt;21320&lt;/span&gt; rules.
Disabled &lt;span class="m"&gt;48&lt;/span&gt; rules.
Enabled &lt;span class="m"&gt;0&lt;/span&gt; rules.
Modified &lt;span class="m"&gt;0&lt;/span&gt; rules.
Enabled &lt;span class="m"&gt;86&lt;/span&gt; rules &lt;span class="k"&gt;for&lt;/span&gt; flowbit dependencies.
Writing rule files to /etc/suricata/rules/.
Writing /etc/suricata/rules/sid-msg.map.
Running post-hook as output has been modified.
Running /etc/init.d/suricata restart.
Stopping suricata:  &lt;span class="k"&gt;done&lt;/span&gt;.
Starting suricata in IDS &lt;span class="o"&gt;(&lt;/span&gt;af-packet&lt;span class="o"&gt;)&lt;/span&gt; mode... &lt;span class="k"&gt;done&lt;/span&gt;.
Done.
&lt;/pre&gt;&lt;/div&gt;</content><category term="ubuntu"></category><category term="ids"></category><category term="suricata"></category></entry><entry><title>Using the let's encrypt for Nginx</title><link href="http://haginara.github.io/posts/2016/07/using-the-lets-encrypt-for-nginx/" rel="alternate"></link><published>2016-07-01T00:00:00-07:00</published><updated>2016-07-01T00:00:00-07:00</updated><author><name>haginara</name></author><id>tag:haginara.github.io,2016-07-01:/posts/2016/07/using-the-lets-encrypt-for-nginx/</id><summary type="html">&lt;p&gt;Verifying your HTTPS service using Let's Encrypt for Nginx&lt;/p&gt;</summary><content type="html">&lt;h1&gt;사전 정보&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;Web Service: Nginx&lt;/li&gt;
&lt;li&gt;Service port: 80(http) / 443(https)&lt;/li&gt;
&lt;li&gt;letsencrypt folder: /opt/letsencrypt&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;인증서 얻기&lt;/h1&gt;
&lt;h2&gt;Client 다운로드&lt;/h2&gt;
&lt;p&gt;인증서를 얻기 위하여 별도의 letsencyrpt 클라이언트 프로그램을 다운 받아야 한다.
해당 클라이언트는 웹서비스를 하고 있는 대상 서버에 다운을 받는다.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;cd /opt
git clone https://github.com/letsencrypt/letsencrypt
cd letsencrypt
&lt;/pre&gt;&lt;/div&gt;


&lt;h2&gt;사용하고 있는 웹서비스 종료 후 인증서 받기&lt;/h2&gt;
&lt;p&gt;인증서를 받기 위하여 자체적으로 혹은 기존 사용하고 있는 웹서비스를 이용하여 인증서를 받는다.
여기서는 기존 서비스를 이용하지않고 클라이언트에서 자체 지원하는 standalone 방식으로 인증서를 받을 예정이다.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;sudo service nginx stop
&lt;/pre&gt;&lt;/div&gt;


&lt;h2&gt;letsencrypt-auto 이용하여 인증서 얻기&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;./letsencrypt-auto certonly --standalone -d www.haginara.net -d cloud.haginara.net -d blog.haginara.net -d wiki.haginara.net -d kanban.haginara.net -d git.haginara.net
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;인증서를 받은 후에는 아래와 같은 축하 메시지를 받게 된다.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at
   /etc/letsencrypt/live/www.haginara.net/fullchain.pem. Your cert
   will expire on 2016-03-02. To obtain a new version of the
   certificate in the future, simply run Let&amp;#39;s Encrypt again.
 - If like Let&amp;#39;s Encrypt, please consider supporting our work by:

   Donating to ISRG / Let&amp;#39;s Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;위 안내문에서 보듯이 /etc/letsencrypt/live 하위 폴더에 인증서가 위치하게 된다.&lt;/p&gt;
&lt;h2&gt;설정 파일 사용하여 인증서 얻기&lt;/h2&gt;
&lt;p&gt;위와 같이 파라미터를 이용하여 인증서를 받을수도 있지만 별도의 설장파일을 만들어 두고 사용 하여도된다.&lt;/p&gt;
&lt;p&gt;cli.ini&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;rsa-key-size = 4096
domains = www.haginara.net, blog.haginara.net, wiki.haginara.net, git.haginara.net, git.haginara.net, cloud.haginara.net
authenticator = standalone
&lt;/pre&gt;&lt;/div&gt;


&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;./letsencrypt-auto certonly --config cli.ini
&lt;/pre&gt;&lt;/div&gt;


&lt;h2&gt;Nginx 서비스에 인증서 적용&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;ssl_certificate     /etc/letsencrypt/live/www.haginara.net/fullchain.pem
ssl_certificate_ke  /etc/letsencrypt/live/www.haginara.net/privkey.pem
&lt;/pre&gt;&lt;/div&gt;


&lt;h2&gt;기존 웹서비스 실행&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;sudo service nginx start
&lt;/pre&gt;&lt;/div&gt;


&lt;h1&gt;정리&lt;/h1&gt;
&lt;p&gt;위 작업을 하나의 스크립트로 만들어 보았다.&lt;/p&gt;
&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt; 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="ch"&gt;#!/bin/bash&lt;/span&gt;

&lt;span class="nv"&gt;INI_PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/opt/letsencrypt/cli.ini
&lt;span class="nv"&gt;NGINX_PID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/var/run/nginx.pid

service nginx stop
sleep &lt;span class="m"&gt;2&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; -f &lt;span class="nv"&gt;$NGINX_PID&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
    service nginx restart
&lt;span class="k"&gt;else&lt;/span&gt;
    &lt;span class="nb"&gt;cd&lt;/span&gt; /opt/letsencrypt
    ./letsencrypt-auto certonly --config &lt;span class="nv"&gt;$INI_PATH&lt;/span&gt;
    service nginx start
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;

&lt;p&gt;위 스크립트는 이후 인증서 갱신시 크론잡에서 호출 할 예정이다.&lt;/p&gt;
&lt;h1&gt;인증서 갱신&lt;/h1&gt;
&lt;p&gt;Let's Encrypt 인증서의 경우 만료기간이 90일이다. 따라서 매 90일 마다 인증서 갱신을 해주어야 한다.&lt;/p&gt;
&lt;p&gt;인증서 갱신은 기존 인증서를 새로 발급 받는 절차와 동일하다 단지 이 작업을 90일마다(인증서 만료전) 실행 해 주기위하여 Cronjob으로 설정할 에정이다.&lt;/p&gt;
&lt;h2&gt;Cron-job&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;sudo crontab -e
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;아래와 같이 크론잡을 설정 해준다.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;30 03 01 */3 * /opt/letsencrypt/letsencrypt-cron
&lt;/pre&gt;&lt;/div&gt;</content><category term="letsencrypt"></category><category term="nginx"></category></entry><entry><title>Welcome</title><link href="http://haginara.github.io/posts/2016/07/welcome/" rel="alternate"></link><published>2016-07-01T00:00:00-07:00</published><updated>2016-07-01T00:00:00-07:00</updated><author><name>haginara</name></author><id>tag:haginara.github.io,2016-07-01:/posts/2016/07/welcome/</id><summary type="html">&lt;p&gt;Welcome Page&lt;/p&gt;</summary><content type="html">&lt;p&gt;This is the welcome page for haginara.github.io&lt;/p&gt;</content><category term="Pelican"></category><category term="publishing"></category></entry></feed>