oui c'est ce que je veux
voila le programme
import java.io.*;
import java.util.StringTokenizer;
public class Discfree
{
public static void main (String [] args) throws IOException
{
String Command = "iptables -L";
Process Findspace = Runtime.getRuntime().exec(Command);
BufferedReader Resultset = new BufferedReader(new InputStreamReader(Findspace.getInputStream()));
String line;
while ((line = Resultset.readLine()) != null)
{
StringTokenizer stok = new StringTokenizer("num target prot opt source destination");
String[] leselements = new String[stok.countTokens()];
int iTok=0;
while (stok.hasMoreTokens())
{
leselements[iTok] = stok.nextToken();
iTok++;
}
for(int j=0;j<leselements.length;j++)
{
System.out.println(leselements[j]);
}
}
}
}
et voila leur execution
num
target
prot
opt
source
destination
num
target
prot
opt
source
destination
num
target
prot
opt
source
destination
num
target
prot
opt
source
destination
num
target
prot
opt
source
destination
num
voila la tables d’iptables :
Chain INPUT (policy DROP)
num target prot opt source destination
1 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
2 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
3 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state NEW
4 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:80
5 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
6 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:23
7 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:53
8 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:20
9 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:21
10 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
Chain FORWARD (policy DROP)
num target prot opt source destination
1 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state NEW
2 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
3 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state NEW,RELATED,ESTABLISHED
4 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state NEW,RELATED,ESTABLISHED,UNTRACKED
5 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
Chain OUTPUT (policy DROP)
num target prot opt source destination
1 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
2 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
3 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
4 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
5 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state NEW
Je veux faire l’exécution de chaque colonne avec ses informations
Merci.