May 02, 2020

How to add line number and syntax highlight using JavaScript.

SyntaxHighlighter.js library makes it easy to highlight line numbers and highlights.
SyntaxHighlighter.js 라이브러리를 이용하면 쉽게 라인 번호와 하이라이트가 가능하다.

Based on the code below, you can modify and use according to your preference.
아래의 코드를 바탕으로 개인에 기호에 따라 수정하여 사용하면 된다.






 
// Insert Source code Here.
function abc(){
    console.log("Hello, world!");
}

The "shBrushXXX.min.js" code is used for highlighting purposes. The computer language(syntax) you wish to highlight can be set to "class = 'brush: XXX;'" in the "pre" element.
"shBrushXXX.min.js" 코드는 하이라이트 목적으로 사용된다. 하이라이트를 희망하는 컴퓨터 언어(문법)는 "pre" 엘리먼트에 "class='brush:XXX;'"로 설정한다.

See the link below for detailed highlight settings.
세부 하이라이트 설정은 아래 링크를 참조한다.


You can specify the line number to start with "first-line: XXX". See the links below for detailed options.
"first-line: XXX"로 시작할 라인 번호를 지정할 수 있다. 기타 세부 옵션은 아래 링크를 참조한다.



September 09, 2019

How to check the hash value of a directory

In fact, by their nature, Directory file cannot be obtained hash value. However, hash of each file in the directory can be obtained.

디렉터리 파일은 그 특성상 해시 값을 구할 수는 없다. 하지만, 디렉터리에 포함된 각 파일의 해시값을 구할 수는 있다.

$ find [path] -exec sha256sum {} \; > 20190430.txt
$ find [path] -exec sha256sum {} \; > 20190530.txt
$ diff 20190430.txt 20190530.txt

The find command recursively traverse all the files in a directory. Then apply a hash command to each file and save the result in a specific file. You can then check the integrity by comparing the two files as needed.

find 명령어를 통해 재귀적인 방식으로 디렉터리 내부의 모든 파일을 순회한다. 그리고 각 파일에 대해 해시 명령어를 적용하여 그 결과를 특정 파일에 저장한다. 이후 필요한 시점에 두 파일을 비교하면 무결성을 점검할 수 있다.




$ find [path] -exec sha256sum {} \; 2>/dev/null | sha256sum
0e64e1ab31b2... *-

As you can see, the result of the traversal is entered again into the hash command, which can be expressed as a single line.

순회한 결과를 다시 해시 명령어에 입력하면, 간단하게 한 줄로 표현할 수 있다.

August 02, 2019

How to create a virtual host on a port basis at apache2/PHP7

1. After opening the "/etc/apache2/ports.conf" file, add the following information.

1. "/etc/apache2/ports.conf" 파일을 오픈한 뒤, 아래와 같이 정보를 추가한다.

# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in # /etc/apache2/sites-enabled/000-default.conf

Listen 8961
Listen 4241
Listen 3317

- Add the port what you want to open using the keyword "Listen".

- 개방하고자 하는 포트를 "Listen" 키워드를 사용하여 추가한다.




2. After opening the "/etc/apache2/sites-available/000-default.conf" file, add the following information.

2. "/etc/apache2/sites-available/000-default.conf" 파일을 열람한 뒤, 아래와 같이 정보를 추가한다.

<VirtualHost *:8961>
    DocumentRoot /var/www/abc1
</VirtualHost>

<VirtualHost *:4241>
    DocumentRoot /var/www/abc2
</VirtualHost>

<VirtualHost *:3317>
    DocumentRoot /var/www/abc3
</VirtualHost>

- Reflect the port you registered in "ports.conf" to the VirtualHost tag.

- "ports.conf"에 등록했던 포트를 VirtualHost 태그에 반영한다.

- Set the root directory of the virtual host using the keyword "DocumentRoot".

- "DocumentRoot" 키워드를 사용하여 해당 가상 호스트의 루트 디렉토리를 지정한다.

May 19, 2019

How to enable root account in Ubuntu

The first time you install Ubuntu, you can not use the root account. Here we discuss how to activate it.

최초 Ubuntu를 설치하면 root 계정을 사용할 수 없다. 여기서는 이를 활성화하는 방법을 다룬다.


1. Set password for root account.  root 계정의 패스워드 설정.
$ sudo passwd root




2. Unlock.  잠금 해제.
How to enable root account in Ubuntu 1

Upper right gear icon → System Settings... → User Accounts → Unlock

우상단 톱니바퀴 아이콘 → System Settings... → User Accounts → Unlock




3. Enable root account login.  root 계정 로그인 활성화.
$ sudo vi /etc/lightdm/lightdm.conf

How to enable root account in Ubuntu 2

Write as above and save. Then reboot.

위와 같이 입력 후 저장한다. 이어서 재부팅한다.

March 01, 2019

How to open OVF file in Vmware.



Just follow the below.
아래를 그대로 따라하시면 됩니다.

OVF 파일 열기

OVF 파일 선택

OVF 저장 위치 선택

OVF 로드

OVF 로드가 완료된 상태.

January 01, 2019

How to make a shellcode using nasm and ld.

Write the following famous shellcode (23 Bytes) as a text file and save it as "mysh.s".
아래의 유명한 쉘코드(23 Bytes)를 텍스트 파일로 작성 후 "mysh.s" 이름으로 저장한다.

BITS 32
global _start

_start:
    xor eax, eax
    mov al, 11
    xor ecx, ecx
    xor edx, edx
    push ecx
    push 0x68732f2f
    push 0x6e69622f
    mov ebx, esp
    int 0x80

"int 80" is the assembly code that uses the system call to interrupt the CPU. On x86 architectures, put the number of the system call you want to call in eax, and on x64 architecture, in rax.

"int 80"은 CPU에 인터럽트를 걸어 시스템 콜을 사용하는 어셈블리 코드다. x86 아키텍처에서는 eax에, x64 아키텍처에서는 rax에 호출하고 싶은 시스템 콜의 번호를 넣으면 된다.

Functionx85x64arg 1arg 2arg 3
read30fdbufcount
write41fdbufcount
execve1159filenameargvenvp
dup26333oldnew
mprotect12510startlenprot

ArchitectureCodeNumberarg 1arg 2arg 3arg 4
x86int 0x80eaxebxecxedxesi
x64syscallraxrdirsirdir10


Enter the following command to make the shellcode executable file.
아래의 명령어를 입력하여 작성한 쉘코드를 컴파일한다.

# nasm -f elf32 ./mysh.s
# ld -m elf_i386 ./mysh.o

"nasm" is an assembler. It creates an object file(mysh.o).
"ld" is a linker. It makes an object file executable(a.out).

"nasm"은 어셈블러이며 오브젝프 파일을 생성한다(mysh.o).
"ld"는 링커이며 오브젝트 파일을 실행파일로 만든다(a.out).
* Linker and Loader[Link]

The supported architecture can be checked with the following command.
지원되는 아키텍처는 아래의 명령어로 확인할 수 있다.

# nasm -hf
# ld -mv 

The generated files have the following file formats.
생성된 파일들은 아래와 같은 파일 형식을 갖는다.

root@ubuntu:~/tmp/shellcode# file ./a.out ./mysh.o ./mysh.s
./a.out:   ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, not stripped
./mysh.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped
./mysh.s: ASCII text

Now run the generated shellcode to test that it works.
이제 생성된 쉘 코드를 실행하여 잘 동작하는지 테스트한다.

root@ubuntu:~/tmp/shellcode# ./a.out
# id
uid=0(root) gid=0(root) groups=0(root)
# echo "Abc"
Abc
# uname -a
Linux ubuntu 4.13.0-43-generic #48~16.04.1-Ubuntu SMP Thu May 17 12:56:46 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
#
# pwd
/root/tmp/shellcode
# echo $0

# bash
root@ubuntu:/root/tmp/shellcode# env | grep -i shlvl
SHLVL=1
root@ubuntu:/root/tmp/shellcode# exit
exit
# ps
   PID TTY          TIME CMD
  2118 pts/11   00:00:00 bash
  3466 pts/11   00:00:00 sh
  3483 pts/11   00:00:00 ps
# exit
root@ubuntu:~/tmp/shellcode#

It works well.
잘 동작한다.


Check environment  점검 환경
O   S Ubuntu 16.04(64 bits) CPU Intel i7
SHELL GNU bash (4.3.48) RAM 1 GB

November 19, 2018

How to install Android in VMware




Android 7.1 rc2 version is used.
안드로이드 7.1 rc2 버전이 사용되었음.


vmware android install accelerate 30 graphics

I recommend you allocate more than 2 GB of memory when adding images in VMware. If you set it to 1 GB, you can know what the pain is as the above video.

VMware에 이미지 추가 시 메모리는 2 GB 이상을 할당하는 것을 권고한다. 만약 1 GB로 설정하면 어떤 고통을 받는지 위의 영상에서 볼 수 있다.

Be sure to select "Accelerate 3D graphics" on the display. If you do not select this, only the Linux shell will be provided when running the OS.

디스플레이에서 3D 그래픽 가속을 반드시 선택한다. 이를 선택하지 않으면 OS 구동 시 리눅스 쉘만 제공된다.




vmware android install first screen.

Select "Installation - Install Adnroid-x86 to harddisk".
"Installation - Install Adnroid-x86 to harddisk" 선택.




VMware android install - partition

Select "Create/Modify partitions".
"Create/Modify partitions" 선택.




VMware android install - no gpt

Do not use GPT.
GPT 미사용.




VMware android install - new partition

Select "New".
"New" 선택.




VMware android install - primary partition

Select "Primary".
"Primary" 선택.



VMware android install - primary partition allocation

Press Enter key to apply the default setting.
기본 설정 그대로 엔터.




VMware android install - primary partition bootable

Select "Bootable".
"Bootable" 선택




VMware android install - write selection

Select "Write" and write "yes".
"Write" 선택후 "yes" 입력.




VMware android install - quit selection

Select "Quit".
"Quit" 선택.




VMware android install - sda1

Select "sda1".
"sda1" 선택.




VMware android install - sda1 format

Select "ext4".
"ext4" 선택.




VMware android install - sda1 format start

Start format.
포맷 시작.




VMware android install - grub

Install "GRUB".
"GRUB" 설치.




VMware android install - read write permission.

Grant read / write permission to the "/ system" directory.
"/system" 디렉토리에 읽기/쓰기 권한 부여.




VMware android install - end of install

Select "Reboot".
"Reboot" 선택.