Saturday 27 August 2016

Enable passive FTP on DD-WRT's ProFTP with CT helpers

Most of the popular web browsers (Chrome, MS Edge, FFox) forces passive FTP mode on client side when connecting to FTP server. This can be a problem if you are using ProFTP on dd-wrt router and you want to access from the WAN port (from other locations). Main problem is NAT. To solve this problem developers (on some other systems such as Gargoyle and Tomato) uses nf_conntrack_ftp and nf_nat_ftp kernel modules. On kernels above 3.5 this is depricated and using connection tracking helpers (CT helpers) is more secure and recommended. These iptables directives can achive wanted.

First of all enable USB support, Storage support and Automatic Drive Mount.
Then, enable ProFTP without enabling WAN access (we will do it from command line), add mountpoint and create user.
At last place this iptables directives to your firewall:

iptables -I INPUT -i `get_wanface` -p tcp --dport 20 -j ACCEPT 
iptables -I INPUT -i `get_wanface` -p tcp --dport 21 -j ACCEPT 
iptables -I INPUT -i `get_wanface` -p tcp --dport 1024: -j ACCEPT 
iptables -I INPUT -i `get_wanface` -p tcp --dport 21 -m state --state NEW -m recent --set
iptables -I INPUT -i `get_wanface` -p tcp --dport 21 -m state --state NEW -m recent --update --seconds 60 --hitcount 4 -j DROP
iptables -I INPUT -m conntrack --ctstate RELATED -j ACCEPT
iptables -I INPUT -m helper --helper ftp -j ACCEPT
iptables -I OUTPUT -p tcp --sport 20 -j ACCEPT 
iptables -I OUTPUT -p tcp --sport 21 -j ACCEPT 
iptables -I OUTPUT -p tcp --sport 1024: -j ACCEPT 
iptables -t raw -I PREROUTING -p tcp --dport 20 -j CT --helper ftp 
iptables -t raw -I PREROUTING -p tcp --dport 21 -j CT --helper ftp 
iptables -t raw -I PREROUTING -p tcp --dport 1024: -j CT --helper ftp

To check if all is secure try some firewall test like GRC firewall test.

As you can notice, there are green, blue and red squares on the picture above. Green squares means that ports are stealth (invisible?) to hackers. Packets are DROPed on WAN interface on those ports. On port 21 (ProFTP port) our ddwrt unit is listening and waiting for connections so it is marked as red because packets are being ACCEPTed if credentials (username/password) are ok. We have in firewall:

iptables -I INPUT -i `get_wanface` -p tcp --dport 21 -m state --state NEW -m recent --set
iptables -I INPUT -i `get_wanface` -p tcp --dport 21 -m state --state NEW -m recent --update --seconds 60 --hitcount 4 -j DROP

this will limit hackers on 4 tries per minute.

Blue squares on port 20 and ports 1024:65565 meaning that packets are REJECTED if they are not RELATED meaning our ProFTP server is secured.
Now, check your WAN ftp access by connecting with Chrome to ftp://{public_IP} from another location. 





Sunday 21 August 2016

Бројанице и Исусова молитва

Први текст који сам написао а који је био негде објављен био је текст из наслова. Написан је давне 2002.-ге године у Вршцу током редовног служења војног рока. Објављен је у ВОЗ-у (војнички забавник) марта 2002.-ге године у броју 26. Као студент Богословског факултета СПЦ  био сам замољен од стране једног од уредника ВОЗ-а Зденка Лаутера да напишем текст за "духовну радионицу" јер се у то време јављало све веће интересовање за бројанице. Текст преносим у целости.
У Србију, бројанице су дошле са свете Горе Атоске. Уско су повезане са Исихазмом и Светом Гором. У Хиландару српски монаси су "држали правило" сталне молитвене будности изговарањем Исусове молитве. Ово правило светогорских тиховатеља, остало је неизмењено до данашњих дана, па је зато и последњи српски монах на Спасовој води (отац Георгије Витековић - наш савременик) свој духовни живот ујашњавао сталним изговарањем Исусове молитве која гласи: "Господе Исусе Христе, Сине Божији, помилуј ме грешнога (грешну)".
Светогорски монаси, посебно пустиножитељи, данас служе правило Исусове молитве уместо полуноћнице, јутрења и првог часа. Монах тад изврши 33 пута ("изброји" (изговори Исусову молитву)) над 100 куглица/чворова колико има једна велика бројаница. Дакле изговори 3300 пута Исусову молитву.
Број куглица (или "чотки" како их зову руски монаси) у бројаници, као и број пуних кругова целокупне бројанице, уз изговарање Исусове молитве, одређује духовни старац (духовник).
Код бројаница од 100 чотки молитвено правило се врши на следећи начин: за првих 25 чотки обавља се метанија до земље за сваку чотку посебно када се изговори Исусова молитва, за других 25 врши се мала метанија за сваку чотку посебно када се изговори Исусова молитва, онда се за следећих 25 чотки врши осењавање крсним знаком са сваку чотку посебно када се изговара Исусова молитва; за последњих 25 чворова бројанице Исусова молитва је умна и без крштења - онда цео круг на исти начин и то 33 пута!
војник инструктор Х.М.

Thursday 11 August 2016

Enhance your DD-WRT security with additional iptables rules

This howto will help you to block some of most TCP-based DDoS attcks. Although ddwrt has very good firewall it does not hurt to add some extra rules as long as you know what are you doing.
iptables -t mangle -I PREROUTING -m conntrack --ctstate INVALID -j DROP
This rule blocks all packets that are not a SYN packet and don't belong to an established TCP connection.
iptables -t mangle -I PREROUTING -p tcp ! --syn -m conntrack --ctstate NEW -j DROP
This blocks all packets that aren't new (don't belong to an established connection) and don't use SYN flag. This rule is similar to the above rule but I found that it catches some packets that other ones doesn't.

iptables -t mangle -I PREROUTING -p tcp -m conntrack --ctstate NEW -m tcpmss ! --mss 536:65535 -j DROP
The above rule blocks new packets (only SYN packets can be new packets) that use a TCP MSS value that is not common.


To chek if you caught something do from CLI
iptables -vnL -t mangle

How to block Viber ads on DD-WRT router

Rakuten Viber introduced commercials in newer verions of their app so users became products. Often , ads are displayed aggressively a...