Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Stop execution of the file via firewall (riddle)
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Janko33
n00b
n00b


Joined: 06 Mar 2004
Posts: 17

PostPosted: Tue Apr 19, 2005 9:29 am    Post subject: Stop execution of the file via firewall (riddle) Reply with quote

A script excecutes a file which is located on a mounted drive. Mounted drive is on a computer with windows OS somewhere in a network. You have to stop execution of the file. It has to be done via firewall(iptables). Can it be done? How?
Back to top
View user's profile Send private message
ToeiRei
Veteran
Veteran


Joined: 03 Jan 2005
Posts: 1191
Location: Austria

PostPosted: Tue Apr 19, 2005 9:38 am    Post subject: Reply with quote

a firewall can only prevent traffic.
It is impossible to prevent execution of binaries on the firewall without manipulating the protocol.

Rei
_________________
Please stand by - The mailer daemon is busy burning your messages in hell...
Back to top
View user's profile Send private message
Janko33
n00b
n00b


Joined: 06 Mar 2004
Posts: 17

PostPosted: Tue Apr 19, 2005 9:44 am    Post subject: Reply with quote

so how do i stop any traffic related to the excution of the file? (file is located on a computer which is connected on local LAN)
Back to top
View user's profile Send private message
ToeiRei
Veteran
Veteran


Joined: 03 Jan 2005
Posts: 1191
Location: Austria

PostPosted: Tue Apr 19, 2005 9:58 am    Post subject: Reply with quote

there is no traffic related to execution.
you can only block the whole SMB traffic.
An idea would be preventing that with mount options on the client if that is possible

Rei
_________________
Please stand by - The mailer daemon is busy burning your messages in hell...
Back to top
View user's profile Send private message
Janko33
n00b
n00b


Joined: 06 Mar 2004
Posts: 17

PostPosted: Tue Apr 19, 2005 10:21 am    Post subject: Reply with quote

so i can not block smb traffic related to that file only, filter it or something.
Back to top
View user's profile Send private message
ToeiRei
Veteran
Veteran


Joined: 03 Jan 2005
Posts: 1191
Location: Austria

PostPosted: Tue Apr 19, 2005 10:30 am    Post subject: Reply with quote

no.
_________________
Please stand by - The mailer daemon is busy burning your messages in hell...
Back to top
View user's profile Send private message
Janko33
n00b
n00b


Joined: 06 Mar 2004
Posts: 17

PostPosted: Tue Apr 19, 2005 10:38 am    Post subject: Reply with quote

can i somehow through the network traffic detect when the file is excuting? so i stop the smb traffic right after?
Back to top
View user's profile Send private message
rex123
Apprentice
Apprentice


Joined: 21 Apr 2004
Posts: 272

PostPosted: Tue Apr 19, 2005 11:32 am    Post subject: Reply with quote

You could get hold of something that will capture network traffic (eg ethereal). Start capturing, execute the remote file, then analyse the captured traffic. If there's anything identifiable in the traffic that you can work on with a firewall, then you might be able to do what you want. Bear in mind that the firewall knows what protocol is being used, and what IP addresses are being used, but you can't make firewall rules based on the *content* of the data within the SMB protocol (at least, I don't think you can).

This will be an interesting learning experience, but I expect you will finally conclude that ToeiRei is right.
Back to top
View user's profile Send private message
sevo
Tux's lil' helper
Tux's lil' helper


Joined: 12 Mar 2005
Posts: 79

PostPosted: Tue Apr 19, 2005 11:40 am    Post subject: Reply with quote

In theory you can of course filter the protocol used to transfer the file - anything can be filtered, given the right tool. But that would imply much more than "close all SMB traffic if someone attempts to open that file" - for one, you can't safely determine whether the file is being accessed by trivial packet inspection (so you'd need much more than a iptables packet filter), for the other, you can't really want to interrupt everything in response, as that would enable worse attacks than a mere file execution, so you'd have to track state of the SMB session even after determining the file access.

Right now, there is no such thing as the stateful SMB proxy you'd need to deal with the above issues - you would have to write one. Given the reverse engineering issues and general nastyness of SMB/CIFS, that would amount to a nice collaborative project for the master theses of an entire CS class, or a year or more of work for an individual with firm network file system expertise.

That is, the effort (and its impact on performance and network operability) would be way out of proportion to normal server side methods from access control to removing that file.

Sevo
Back to top
View user's profile Send private message
ToeiRei
Veteran
Veteran


Joined: 03 Jan 2005
Posts: 1191
Location: Austria

PostPosted: Tue Apr 19, 2005 11:46 am    Post subject: Reply with quote

An idea for preventing access on cmd.exe would be
Code:
iptables -I INPUT -j DROP -p tcp -s 0.0.0.0/0 --dport 139 -m string --string "cmd.exe"

but this also prevents file-listings (that would be dropping every packet with the matching string) - beware of protocol violations.

Rei
_________________
Please stand by - The mailer daemon is busy burning your messages in hell...
Back to top
View user's profile Send private message
Janko33
n00b
n00b


Joined: 06 Mar 2004
Posts: 17

PostPosted: Tue Apr 19, 2005 12:50 pm    Post subject: Reply with quote

the last post could help i will try it
Back to top
View user's profile Send private message
ToeiRei
Veteran
Veteran


Joined: 03 Jan 2005
Posts: 1191
Location: Austria

PostPosted: Tue Apr 19, 2005 12:56 pm    Post subject: Reply with quote

the string should be the binary code of the executable which should be prevented.
but I do not give any warranty that it works.

btw - you will have to patch your kernel and iptables with the latest patch-o-matic from iptables.org

Rei
_________________
Please stand by - The mailer daemon is busy burning your messages in hell...
Back to top
View user's profile Send private message
Janko33
n00b
n00b


Joined: 06 Mar 2004
Posts: 17

PostPosted: Tue Apr 19, 2005 1:17 pm    Post subject: Reply with quote

and i thought it would be easy but i will look for help around string thing
Back to top
View user's profile Send private message
ToeiRei
Veteran
Veteran


Joined: 03 Jan 2005
Posts: 1191
Location: Austria

PostPosted: Tue Apr 19, 2005 1:57 pm    Post subject: Reply with quote

I've never said it would be easy. Opening the executeable which should be blocked with a text-editor should give you strings.
_________________
Please stand by - The mailer daemon is busy burning your messages in hell...
Back to top
View user's profile Send private message
mekong
Tux's lil' helper
Tux's lil' helper


Joined: 23 Apr 2004
Posts: 93
Location: Rdam - NL - EU

PostPosted: Tue Apr 19, 2005 2:18 pm    Post subject: Reply with quote

Hi, you could add "noexec" option when you mount the network drive to disable execution.

"mount device mountpoint -o noexec" or just add noexec in the file /etc/fstab
Back to top
View user's profile Send private message
ScRaTcHi
n00b
n00b


Joined: 21 Dec 2004
Posts: 62

PostPosted: Fri May 20, 2005 11:43 am    Post subject: Reply with quote

A note:

Eeach file executed over the network is first copied into clients paging file before execution since Windows version 95.

Another note:

All windows executable files (.EXE) have 'MZ' header (first two bytes in that file). Pure windows 32bit executable files compiled with most modern compilers contain text 'This program cannot be run in DOS mode.' or 'This program must be run under Win32'. That might help You filter those files using appropriate iptables matches. ;)
_________________
ScRaTcHi

-----------------------------------------------------------

Never trust an operating system you don't have sources for.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum