📜 ⬆️ ⬇️

Linux. Conky. Monitor Counter-Strike Servers

Recently digging into old deposits of written code, I came across my old project. When he wrote, it was planned to make a fake Counter-Strike server, which will exploit the vulnerability in the Counter-Strike client. Later it turned out that only version 1.5 is vulnerable. I abandoned this case. In general, having recently found the source, I decided to make this a program for monitoring Counter-Strike servers. That's what came out of it:

And so in conky there is such a parameter as $ {execi}, which can periodically execute any program. This and use in the future.
Download the archive with executable files and sources. As we can see, everything was written on JAVA (Do not kick much, did not want to rewrite something kosher, and there’s no need - there are no brakes), so you have to install JRE:
sudo aptitude install sun-java6-jre
For other distributions, it’s the same (only the package manager is different), unless you decide to install the off version (in this case, I send you to the oracle mana off)
We check work:
java -version
Should bring something like that:
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) Server VM (build 16.3-b01, mixed mode)

And so the virtual machine is ready for battle. Now unzip monitoring.zip. The monitor folder contains executable files. Since Java’s main motto is “Write once, run everywhere”, you don’t have to compile anything. In this folder there is a ListServers file. We edit it, namely we enter servers with ports through a colon. For example:
cs.gtn.ru:27015
cs.gtn.ru:27016

You can and ip address.
Next, for convenience, rename the folder to .monitor and copy to your home directory. It remains only to install conky and edit its config.
sudo aptitude install conky
Next, copy the standard .conkyrc config file to your home folder. You can take it off. site or mine (my need to rename to .conkyrc)
In general, now we need to edit our cofig.
In the section TEXT we enter:
${color white}${execi 10 cd .monitor/ && java CounterStrikeMonitor}

This program will run every 10 seconds. Save and run conky.
You should get something like this:

image

There are also source codes. As you can see, I do not display all the information. In the class CounterStrikesParser there are lists of players and their points:
private ArrayList users ;
private int[] scores ;


, .

.

UdpConnect - udp . .
CounterStrikeConnect - UdpConnect. Counter-Strike , WireShark. , . getData()
CounterStrikesParser - . 2 byte - . ParseFirstUdpPacket() ParseSecondUdpPacket() , . :

private ArrayList users ;
private int[] scores ;
private String nameServer ;
private String map ;
private int nomberOfGamers ;
private int maxGamers ;


CounterStrikeMonitor - . :
//
CounterStrikeConnect connect = new CounterStrikeConnect (ip, port);
// 2
// getData() connect
// 2
CounterStrikesParser parser = new CounterStrikesParser ( connect .getData(), connect .getData());
parser .ParseFirstUdpPacket(); //
parser .ParseSecondUdpPacket(); //
//
System.out.println("Name: " + parser .getNameServer());

private ArrayList users ;
private int[] scores ;


, .

.

UdpConnect - udp . .
CounterStrikeConnect - UdpConnect. Counter-Strike , WireShark. , . getData()
CounterStrikesParser - . 2 byte - . ParseFirstUdpPacket() ParseSecondUdpPacket() , . :

private ArrayList users ;
private int[] scores ;
private String nameServer ;
private String map ;
private int nomberOfGamers ;
private int maxGamers ;


CounterStrikeMonitor - . :
//
CounterStrikeConnect connect = new CounterStrikeConnect (ip, port);
// 2
// getData() connect
// 2
CounterStrikesParser parser = new CounterStrikesParser ( connect .getData(), connect .getData());
parser .ParseFirstUdpPacket(); //
parser .ParseSecondUdpPacket(); //
//
System.out.println("Name: " + parser .getNameServer());

private ArrayList users ;
private int[] scores ;


, .

.

UdpConnect - udp . .
CounterStrikeConnect - UdpConnect. Counter-Strike , WireShark. , . getData()
CounterStrikesParser - . 2 byte - . ParseFirstUdpPacket() ParseSecondUdpPacket() , . :

private ArrayList users ;
private int[] scores ;
private String nameServer ;
private String map ;
private int nomberOfGamers ;
private int maxGamers ;


CounterStrikeMonitor - . :
//
CounterStrikeConnect connect = new CounterStrikeConnect (ip, port);
// 2
// getData() connect
// 2
CounterStrikesParser parser = new CounterStrikesParser ( connect .getData(), connect .getData());
parser .ParseFirstUdpPacket(); //
parser .ParseSecondUdpPacket(); //
//
System.out.println("Name: " + parser .getNameServer());

private ArrayList users ;
private int[] scores ;


, .

.

UdpConnect - udp . .
CounterStrikeConnect - UdpConnect. Counter-Strike , WireShark. , . getData()
CounterStrikesParser - . 2 byte - . ParseFirstUdpPacket() ParseSecondUdpPacket() , . :

private ArrayList users ;
private int[] scores ;
private String nameServer ;
private String map ;
private int nomberOfGamers ;
private int maxGamers ;


CounterStrikeMonitor - . :
//
CounterStrikeConnect connect = new CounterStrikeConnect (ip, port);
// 2
// getData() connect
// 2
CounterStrikesParser parser = new CounterStrikesParser ( connect .getData(), connect .getData());
parser .ParseFirstUdpPacket(); //
parser .ParseSecondUdpPacket(); //
//
System.out.println("Name: " + parser .getNameServer());

private ArrayList users ;
private int[] scores ;


, .

.

UdpConnect - udp . .
CounterStrikeConnect - UdpConnect. Counter-Strike , WireShark. , . getData()
CounterStrikesParser - . 2 byte - . ParseFirstUdpPacket() ParseSecondUdpPacket() , . :

private ArrayList users ;
private int[] scores ;
private String nameServer ;
private String map ;
private int nomberOfGamers ;
private int maxGamers ;


CounterStrikeMonitor - . :
//
CounterStrikeConnect connect = new CounterStrikeConnect (ip, port);
// 2
// getData() connect
// 2
CounterStrikesParser parser = new CounterStrikesParser ( connect .getData(), connect .getData());
parser .ParseFirstUdpPacket(); //
parser .ParseSecondUdpPacket(); //
//
System.out.println("Name: " + parser .getNameServer());

private ArrayList users ;
private int[] scores ;


, .

.

UdpConnect - udp . .
CounterStrikeConnect - UdpConnect. Counter-Strike , WireShark. , . getData()
CounterStrikesParser - . 2 byte - . ParseFirstUdpPacket() ParseSecondUdpPacket() , . :

private ArrayList users ;
private int[] scores ;
private String nameServer ;
private String map ;
private int nomberOfGamers ;
private int maxGamers ;


CounterStrikeMonitor - . :
//
CounterStrikeConnect connect = new CounterStrikeConnect (ip, port);
// 2
// getData() connect
// 2
CounterStrikesParser parser = new CounterStrikesParser ( connect .getData(), connect .getData());
parser .ParseFirstUdpPacket(); //
parser .ParseSecondUdpPacket(); //
//
System.out.println("Name: " + parser .getNameServer());


')

Source: https://habr.com/ru/post/100924/


All Articles