LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 08-23-2004, 02:16 PM   #1
unixfreak
Member
 
Registered: Jul 2004
Distribution: Linux 2.4.21-0.13mdk, W2K
Posts: 412

Rep: Reputation: 30
Configuring my Mandrake security problem


Hello

I went to www.grc.com and I tested the File Sharing Probe and also tested the Common Ports.

The results were the following below.

File Sharing Results:
Cannot connect to NetBios or Port 139 (thats very good)

Common Ports Test Results:
ALL Ports were CLOSED instead of OPEN.

Now, all I need to do, is make these ports stealth. But, under Services/Shorewall, I selected START Shorewall and I was not able to view webpages.

So, how would I configure the security to make these ports all STEALTH??

Should I select the Security setting under DrakSec to "High" instead of "Standard"?

Im not using any of the Servers like Samba or Apache. Its just the Internet, email. Thats it.

I need to know how to configure the ports to make them Stealth.

Last edited by unixfreak; 08-23-2004 at 02:49 PM.
 
Old 08-23-2004, 09:07 PM   #2
qwijibow
LQ Guru
 
Registered: Apr 2003
Location: nottingham england
Distribution: Gentoo
Posts: 2,672

Rep: Reputation: 47
shorewall is a security program desighed to do very complicated things like firewall servers / routers and all that kind of thing.....

you requirements are very very very very very basic... you dont need shorewall... just use the basic firewall script.. somthing like...

modprobe ip_conntrack_ftp
iptables -F
iptables -Z
iptables -P OUTPUT ACCEPT
iptables -P INPUT DROP
iptables -A INPUT -i lo -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

done....
all your ports are stealthed...
your machine will not reply to pings...

but things like email, internet, instant messaging.. will work fine.
 
Old 08-24-2004, 01:01 AM   #3
unixfreak
Member
 
Registered: Jul 2004
Distribution: Linux 2.4.21-0.13mdk, W2K
Posts: 412

Original Poster
Rep: Reputation: 30
Yes, your right, its very basic. I DO NOT use any webservers, or anything hardcore like that. Just Internet and Email. Thats it. And offline stuff.

Now, to stealth all my ports EXCEPT Internet, Email, how would I do that exactly. I saw the script that you posted above. Should I Copy/Paste to a text editor??? Or I dont know how this works.

Where in Linux is the Firewall Script Configs located in??? I see people posting IPTABLE Scripts but I do not know where to put these scripts in or where or how to configure them.

Or, if you dont mind, could you please post the script for my basic needs and then explain to me on where to put this script in ???

Im a real newbie in Linux security. I read sooooo many articles on Linux security and I still do not get the point.

Please explain the exact steps on doing this. Also I typed in "iptables -h" as a command and it came up with things that I do not understand.

I would very much appreciate it.

A few notes: Im using a Dial-up connection. With a dynamic IP address....I assume.

Last edited by unixfreak; 08-24-2004 at 01:27 AM.
 
Old 08-24-2004, 05:24 AM   #4
jeroen94704
LQ Newbie
 
Registered: Sep 2003
Posts: 6

Rep: Reputation: 0
In the directory "/etc/shorewall" are two files: "rules" and "policy". Could you post the contents of those files here for us to take a look at? Note that there is a lot of comment (lines starting with #) in both these files, please skip that, it is not necessary and will clutter your post.

Jeroen
 
Old 08-24-2004, 09:37 AM   #5
qwijibow
LQ Guru
 
Registered: Apr 2003
Location: nottingham england
Distribution: Gentoo
Posts: 2,672

Rep: Reputation: 47
okay.. sorry, you sounded like you knew a little about firewalls when i landed that script on you...

ookay... a closed port will reply to an attempted connection with a "go away" messge.... a stealthed port will just drop the connection attempt.

the only rule that effects non local traffic in that rule, is the ESTABLISHED,RELATED rule...

this rule uses clever connection tracking to determine who started the connection.

if the connection was started by you machine... for example, your machine requestion a web-page from google... then the ESTABLISHED rule allows google to reply...

but if for example google sent you a message without you requesting the message, then the message will be totally ignore, and google assumes you are not online.

so, all your ports are stealthed.... EXCEPT for when anouther machine is replying to a connection you started.

ithe script i wrote has no restrictions on outgoing traffic... so you can use any clients... if you want to be untra-parranoid... add these rules...

iptables -A OUTPUT -o lo -s 127.0.0.1 -s 127.0.0.1 -j ACCEPT
iptables -A OUPTUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -p tcp --dport http -j ACCEPT
iptables -A OUTPUT -p tcp --dport https -j ACCEPT
iptables -A OUTPUT -p tcp --dport ftp -j ACCEPT
iptables -A OUTPUT -p tcp --dport pop3 -j ACCEPT
iptables -A OUTPUT -p tcp --dport smtp -j ACCEPT
iptables -A OUTPUT -p icmp --icmp-type echo-request -j ACCEPT
iptables -P OUTPUT DROP

with theseadditions, you machine will onlt be able to ..
* send and recieve email
* download files
* browse the internet
* browse the internet though encrypted connections
* ping other people, but not let other people ping you.

basically, to put the rules into effect.....

copy this text, and paste it at the bottom of your rc.local (which will be somewhere in your /etc/rc.d or /etc/init.d flder, depending on ourdistro) also, dissable shorewall.

Code:
modprobe ip_conntrack_ftp
iptables -F
iptables -Z
iptables -P OUTPUT ACCEPT
iptables -P INPUT DROP
iptables -A INPUT -i lo -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

// optional, for over the top paranoid (and possibly limiting) security
iptables -A OUTPUT -o lo -s 127.0.0.1 -s 127.0.0.1 -j ACCEPT
iptables -A OUPTUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -p tcp --dport http -j ACCEPT
iptables -A OUTPUT -p tcp --dport https -j ACCEPT
iptables -A OUTPUT -p tcp --dport ftp -j ACCEPT
iptables -A OUTPUT -p tcp --dport pop3 -j ACCEPT
iptables -A OUTPUT -p tcp --dport smtp -j ACCEPT
iptables -A OUTPUT -p icmp --icmp-type echo-request -j ACCEPT
iptables -P OUTPUT DROP
 
Old 08-24-2004, 11:32 AM   #6
unixfreak
Member
 
Registered: Jul 2004
Distribution: Linux 2.4.21-0.13mdk, W2K
Posts: 412

Original Poster
Rep: Reputation: 30
Im using Mandrake 9.1.

Which Script do I have to use?? You gave me two.

iptables -A OUTPUT -o lo -s 127.0.0.1 -s 127.0.0.1 -j ACCEPT
iptables -A OUPTUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -p tcp --dport http -j ACCEPT
iptables -A OUTPUT -p tcp --dport https -j ACCEPT
iptables -A OUTPUT -p tcp --dport ftp -j ACCEPT
iptables -A OUTPUT -p tcp --dport pop3 -j ACCEPT
iptables -A OUTPUT -p tcp --dport smtp -j ACCEPT
iptables -A OUTPUT -p icmp --icmp-type echo-request -j ACCEPT
iptables -P OUTPUT DROP

Or this?

code:

modprobe ip_conntrack_ftp
iptables -F
iptables -Z
iptables -P OUTPUT ACCEPT
iptables -P INPUT DROP
iptables -A INPUT -i lo -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

// optional, for over the top paranoid (and possibly limiting) security
iptables -A OUTPUT -o lo -s 127.0.0.1 -s 127.0.0.1 -j ACCEPT
iptables -A OUPTUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -p tcp --dport http -j ACCEPT
iptables -A OUTPUT -p tcp --dport https -j ACCEPT
iptables -A OUTPUT -p tcp --dport ftp -j ACCEPT
iptables -A OUTPUT -p tcp --dport pop3 -j ACCEPT
iptables -A OUTPUT -p tcp --dport smtp -j ACCEPT
iptables -A OUTPUT -p icmp --icmp-type echo-request -j ACCEPT
iptables -P OUTPUT DROP




Last edited by unixfreak; 08-24-2004 at 12:05 PM.
 
Old 08-24-2004, 11:45 AM   #7
unixfreak
Member
 
Registered: Jul 2004
Distribution: Linux 2.4.21-0.13mdk, W2K
Posts: 412

Original Poster
Rep: Reputation: 30
This the way I did it. Please tell me if this is right.
Do I need to Restart the computer for this to take effect???
Look below:
This my (rc.local) file with the Pasted Script Rules:

Look below:

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

[ -f /etc/sysconfig/msec ] && source /etc/sysconfig/msec
[ -z "$SECURE_LEVEL" ] && SECURE_LEVEL=3

# Source functions
. /etc/init.d/functions

if [ -f /etc/mandrake-release -a $SECURE_LEVEL -lt 4 ]; then
R=$(cat /etc/mandrake-release)

arch=$(uname -m)
a="a"
case "_$arch" in
_a*) a="an";;
_i*) a="an";;
esac

NUMPROC=`egrep -c "^cpu[0-9]+" /proc/stat`
if [ "$NUMPROC" -gt "1" ]; then
SMP="$NUMPROC-processor "
[ "$NUMPROC" = "2" ] && \
SMP="Dual-processor "
if [ "$NUMPROC" = "8" -o "$NUMPROC" = "11" ]; then
a="an"
else
a="a"
fi
fi

# This will overwrite /etc/issue at every boot. So, make any changes you
# want to make to /etc/issue here or you will lose them when you reboot.

if [ -x /usr/bin/linux_logo ];then
/usr/bin/linux_logo -c -n -f | sed -e 's|\\|\\\\|g' > /etc/issue
echo "" >> /etc/issue
else
> /etc/issue
fi
echo "$R" >> /etc/issue
echo "Kernel $(uname -r) on $a $SMP$(uname -m) / \l" >> /etc/issue

if [ "$SECURE_LEVEL" -le 3 ];then
echo "Welcome to ${HOST}" > /etc/issue.net
echo "$R" >> /etc/issue.net
echo "Kernel $(uname -r) on $a $SMP$(uname -m)" >> /etc/issue.net
else
echo "Welcome to Mandrake Linux" > /etc/issue.net
echo "-------------------------" >> /etc/issue.net
fi
elif [ $SECURE_LEVEL -ge 4 ]; then
rm -f /etc/issue /etc/issue.net
fi

touch /var/lock/subsys/local

modprobe ip_conntrack_ftp
iptables -F
iptables -Z
iptables -P OUTPUT ACCEPT
iptables -P INPUT DROP
iptables -A INPUT -i lo -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

// optional, for over the top paranoid (and possibly limiting) security
iptables -A OUTPUT -o lo -s 127.0.0.1 -s 127.0.0.1 -j ACCEPT
iptables -A OUPTUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -p tcp --dport http -j ACCEPT
iptables -A OUTPUT -p tcp --dport https -j ACCEPT
iptables -A OUTPUT -p tcp --dport ftp -j ACCEPT
iptables -A OUTPUT -p tcp --dport pop3 -j ACCEPT
iptables -A OUTPUT -p tcp --dport smtp -j ACCEPT
iptables -A OUTPUT -p icmp --icmp-type echo-request -j ACCEPT
iptables -P OUTPUT DROP

Please tell me if this is correct. Or do I need to restart???

Last edited by unixfreak; 08-24-2004 at 12:03 PM.
 
Old 08-24-2004, 12:41 PM   #8
qwijibow
LQ Guru
 
Registered: Apr 2003
Location: nottingham england
Distribution: Gentoo
Posts: 2,672

Rep: Reputation: 47
the script will take effect next time rc.local runs....
you can run it without rebooting... but a re-boot is the most simple way....

afdter you re-boot... please post the output of the command
iptables -vL (as root)

just to be sure these set of rules are the only ones in place...
then have a play round, make sure everything you need to work still works.

OOPS.. just noticed somthing.... where i wriote // optional .... replace // with a hash '#' i was in c++ mode instead of bash, lol.
 
Old 08-24-2004, 12:54 PM   #9
unixfreak
Member
 
Registered: Jul 2004
Distribution: Linux 2.4.21-0.13mdk, W2K
Posts: 412

Original Poster
Rep: Reputation: 30
You mean like this???

# optional, for over the top paranoid (and possibly limiting) security


Also you did not tell me if the above actions in (Post #7) that I posted were correct or not. Please tell me if I Pasted the script in the right position. I would appreciate it.

And also you did not mention which script rule do I have paste foe maximum security.

Thanks

Last edited by unixfreak; 08-24-2004 at 12:57 PM.
 
Old 08-24-2004, 01:24 PM   #10
unixfreak
Member
 
Registered: Jul 2004
Distribution: Linux 2.4.21-0.13mdk, W2K
Posts: 412

Original Poster
Rep: Reputation: 30
WHAT DID YOU DO TO MY SYSTEM!!!!!!!!!!!!!???????????????????/

IT TOTALLY CRASHED ON BOOT UP!!!!!!!!!!!!!!!!!!!!!

NOW I CANT EVEN OPEN UP GEDIT TO DELETE THE SCRIPT I PASTED.

WHEN I BOOT UP LINUX, IT SHOWS INITIALIZING SERVICES FOR ABOUT 5 MINUTES AND THEN IT STARTS TO LOAD UP THE APPLICATIONS AND ICONS ON THE DESKTOP VERY VERY SLOWLY.

NOW HOW COULD I FIX THIS PROBLEM???
 
Old 08-24-2004, 02:58 PM   #11
unixfreak
Member
 
Registered: Jul 2004
Distribution: Linux 2.4.21-0.13mdk, W2K
Posts: 412

Original Poster
Rep: Reputation: 30
OH............AND THANKS FOR DESTROYING MY SYSTEM!!!!!!!!!
 
Old 08-24-2004, 04:08 PM   #12
stickman
Senior Member
 
Registered: Sep 2002
Location: Nashville, TN
Posts: 1,552

Rep: Reputation: 53
If the only thing wrong with your system is some overly protective firewall rules, then your system is not destroyed. Just undo the rules.
 
Old 08-24-2004, 04:11 PM   #13
unixfreak
Member
 
Registered: Jul 2004
Distribution: Linux 2.4.21-0.13mdk, W2K
Posts: 412

Original Poster
Rep: Reputation: 30
I cant even go back to GEDIT to undo them
 
Old 08-24-2004, 04:18 PM   #14
stickman
Senior Member
 
Registered: Sep 2002
Location: Nashville, TN
Posts: 1,552

Rep: Reputation: 53
Does your system boot up? I would assume that it does since you only made firewall changes. When the system starts up, just jump over to a console screen, login as root, edit rc.local with vi, and reboot.
 
Old 08-24-2004, 04:27 PM   #15
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally posted by unixfreak
WHAT DID YOU DO TO MY SYSTEM!!!!!!!!!!!!!???????????????????/

IT TOTALLY CRASHED ON BOOT UP!!!!!!!!!!!!!!!!!!!!!

NOW I CANT EVEN OPEN UP GEDIT TO DELETE THE SCRIPT I PASTED.

WHEN I BOOT UP LINUX, IT SHOWS INITIALIZING SERVICES FOR ABOUT 5 MINUTES AND THEN IT STARTS TO LOAD UP THE APPLICATIONS AND ICONS ON THE DESKTOP VERY VERY SLOWLY.

NOW HOW COULD I FIX THIS PROBLEM???:mad: :mad: :mad: :mad: :mad: :mad:

How about starting to actually read the man-pages and
excellent tutorials on the iptables homepage instead of
trying others to make sense of your postings and abusing
them when what they're trying doesn't quite pose what
you expect?

And more to the point, why don't you go and work through
Machtelt's guide to linux and the Rute Tutorial
before trying to use a linux-install in real-life?
People commonly don't start up a truck without having
used a motor vehicle in the past and then yell for support
and instructions at passing by people....


Cheers,
Tink
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Configuring Mouse Options on Mandrake Caused Problem in Boot-Up ats8 Linux - Laptop and Netbook 1 05-28-2005 10:44 PM
Problems Configuring Security via Mandrake Control Center vous Mandriva 5 03-17-2005 06:20 AM
Configuring Firewall and Security Mic Q SUSE / openSUSE 1 01-19-2005 06:29 AM
problem configuring display properties in mandrake 10 install surlymike Mandriva 1 09-01-2004 08:18 PM
Configuring IPTABLES/Kernel security Thomas M. Linux - Security 1 02-26-2004 11:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 08:56 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration