Browse Source

changed server config, lib, small bugfix for iptables and added NameServer

- changed the server config: all the ports are added to the config in the
  CIFS implementation part
- lib is allowed to make broadcasts on udp
- added one iteration in the for loop of the port redirection
- added a NetBIOS Name Server in the CIFS implemenation part
Daniel Lazar 9 years ago
parent
commit
dc32738a84

+ 1 - 1
assets/payload/redirect-ports.sh

@@ -10,7 +10,7 @@ destination=( 28144 28169 28217 28580 28274 28275 28274 28276 28159 28160 28582)
 length=${#protocol[@]} # count protocol elements
 
 # for (( i=0; i<$length; i++ ))
-for i in `seq 0 9` # fix for android's annoyingly limited bash
+for i in `seq 0 10` # fix for android's annoyingly limited bash
 do
 	# echo ${protocol[$i]} ${origin[$i]} ${destination[$i]} # debug
 

BIN
libs/alfresco-jlan.jar


+ 6 - 8
res/raw/jlan_config.xml

@@ -7,16 +7,14 @@
     </servers>
 
     <SMB>
-        <host name="JLANSRV" domain="ALFRESCO">
-            <broadcast>192.168.1.255</broadcast>
+        <host name="JLANSRV" domain="WORKGROUP">
+            <broadcast>192.168.3.255</broadcast>
             <smbdialects>LanMan,NT</smbdialects>
             <comment>Alfresco JLAN Server</comment>
-
+            <disableNIO/>
             <!-- To run the server using a non-root account on linux, Mac OS X, Solaris -->
             <netBIOSSMB sessionPort="28276" namingPort="28274" datagramPort="28275"/>
-            <tcpipSMB port="28582"/>
-
-
+            <tcpipSMB port="28582" ipv6="disabled"/>
             <hostAnnounce interval="5"/>
         </host>
         <sessionDebug flags="Negotiate,Socket,Tree"/>
@@ -24,8 +22,8 @@
         <announceDebug/>
 
         <authenticator type="local">
-            <mode>USER</mode>
-            <NOallowGuest/>
+            <mode>SHARE</mode>
+            <allowGuest/>
             <Debug/>
         </authenticator>
     </SMB>

+ 14 - 2
src/de/tudarmstadt/informatik/hostage/protocol/CIFS.java

@@ -6,6 +6,9 @@ import android.net.DhcpInfo;
 import android.net.wifi.WifiManager;
 
 import org.alfresco.jlan.app.CifsOnlyXMLServerConfiguration;
+import org.alfresco.jlan.netbios.server.AddNameListener;
+import org.alfresco.jlan.netbios.server.NetBIOSNameEvent;
+import org.alfresco.jlan.netbios.server.NetBIOSNameServer;
 import org.alfresco.jlan.server.SessionListener;
 import org.alfresco.jlan.server.SrvSession;
 import org.alfresco.jlan.server.config.InvalidConfigurationException;
@@ -24,9 +27,10 @@ import de.tudarmstadt.informatik.hostage.R;
 import de.tudarmstadt.informatik.hostage.ui.activity.MainActivity;
 import de.tudarmstadt.informatik.hostage.wrapper.Packet;
 
-public class CIFS implements Protocol, SessionListener, FileListener {
+public class CIFS implements Protocol, SessionListener, FileListener{
     private Listener mHandler;
     private SMBServer mSmbServer;
+    private NetBIOSNameServer mNbNameServer;
 
     public void initialize(Listener mHandler) {
         this.mHandler = mHandler;
@@ -37,12 +41,19 @@ public class CIFS implements Protocol, SessionListener, FileListener {
             smbConfig.loadConfiguration(new InputStreamReader(MainActivity.context.getResources().openRawResource(R.raw.jlan_config)));
             CIFSConfigSection cifsConfig = (CIFSConfigSection) smbConfig.getConfigSection(CIFSConfigSection.SectionName);
             cifsConfig.setBroadcastMask(getBroadcastAddress());
-
+            cifsConfig.setSessionPort(28276);
+            cifsConfig.setTcpipSMBPort(28582);
+            cifsConfig.setDatagramPort(28274);
+            cifsConfig.setHostAnnouncerPort(28275);
+            cifsConfig.setNetBIOSSMB(true);
+            cifsConfig.setDisableNIOCode(true);
 
             this.mSmbServer = new SMBServer(smbConfig);
+            this.mNbNameServer = new NetBIOSNameServer(smbConfig);
             this.mSmbServer.addSessionListener(this);
             this.mSmbServer.addFileListener(this);
 
+            this.mNbNameServer.startServer();
             this.mSmbServer.startServer();
         } catch (IOException e) {
             e.printStackTrace();
@@ -116,4 +127,5 @@ public class CIFS implements Protocol, SessionListener, FileListener {
             quads[k] = (byte) (broadcast >> (k * 8));
         return InetAddress.getByAddress(quads).toString().substring(1);
     }
+
 }

+ 3 - 1
src/de/tudarmstadt/informatik/hostage/protocol/cifs/PseudoCIFSDiskDriver.java

@@ -1,6 +1,6 @@
 package de.tudarmstadt.informatik.hostage.protocol.cifs;
 
-import org.alfresco.config.ConfigElement;
+//import org.alfresco.config.ConfigElement;
 import org.alfresco.jlan.server.SrvSession;
 import org.alfresco.jlan.server.core.DeviceContext;
 import org.alfresco.jlan.server.core.DeviceContextException;
@@ -10,6 +10,7 @@ import org.alfresco.jlan.server.filesys.FileOpenParams;
 import org.alfresco.jlan.server.filesys.NetworkFile;
 import org.alfresco.jlan.server.filesys.SearchContext;
 import org.alfresco.jlan.server.filesys.TreeConnection;
+import org.springframework.extensions.config.ConfigElement;
 
 import java.io.FileNotFoundException;
 import java.io.IOException;
@@ -105,6 +106,7 @@ public class PseudoCIFSDiskDriver implements DiskInterface {
         return null;
     }
 
+
     @Override
     public void treeOpened(SrvSession srvSession, TreeConnection treeConnection) {