28 July 2019

Windows 10 mouse pointer pause/stutter and audio crackling issue.

The mouse stops responding for 0.5 seconds or thereabouts, then starts to operate normally then stutters again and so on. (rinse and repeat)
Audio is also clicking and crackling intermittently when playing any audio source, web based, or mp3, ogg, or flac files, as well as playing CD/DVD's.
Things tried so far in the order done, and their result.
1) Searches indicate that it can be fixed by un-ticking "Enhance pointer precision" in the "Motion" section of the "Pointer Options" tab of "Mouse Properties" in the original version of "Control Panel".
This appears to work so far, the clicking audio also appears to have disappeared with this one change.
I'm still not convinced, and I'll update this after a day of use.

To do this, click "Search" on the task bar, and type "control panel" in the search box, then click on the result to open up "Control Panel". Click on "Mouse" in "Control Panel", and then click on the "Pointer Options" tab now you will see the tick box for "Enhanced pointer precision" just under the pointer speed slider. Remove the tick from the box and click "OK" at the bottom of the window.
Now do the things that used to make the mouse stutter and see if the issue still exists.

06 July 2019

A short how-to and information about nmap-nc which is the preferred replacement for netcat in Linux and *nix like operating systems.

nmap-nc is the name of the tool.

The command typed to invoke the improved version is either nc or ncat.

Examples were assembled from various pages on various sites on the Internet/Interweb, some are listed below. (more to come as I find them)

Examples :-

Listen on a given port (in this case port 8080) for incoming traffic.

ncat -l 8080

Connect to a remote system. (IP-address and port 80)

ncat 80

A connection will now be made to port 80 on the server with an IP address of .  We can now send instructions to the server.

Connecting to UDP ports
By default, the nc utility makes connections only to TCP ports. However using the -u option, we can also listen on UDP ports.

ncat -l -u 1234

Our system will start listening on udp port ‘1234’, we can verify this using the below netstat or ss command. (as netstat is now deprecated on Linux systems)
netstat -tunlp | grep 1234
ss -tunlp | grep 1234

Let’s assume we want to send or test UDP port connectivity to a specific remote host. We would then use the following command.

ncat -v -u host-ip udp-port
ncat -v -u 53

The -v can be removed as all it does is show the version of ncat you are using.

NC as a chat tool

NC can also be used as a chat tool, we can configure the server to listen to a port & then we can make a connection to this server from a remote machine & start sending a message. 
On the server side, run.

ncat -l 8080

On the client machine run
ncat 8080

Now start sending messages & they will be displayed on the remote server's terminal.

NC as a proxy

NC can also be used as a proxy with a simple command. Let’s take an example,

ncat -l 8080 | ncat 80

Now all the connections coming to our server on port 8080 will be automatically redirected to the server on port 80. But since we are using a pipe, data can only be transferred to the server.
In order to receive the data it sends back, we need to create a two way pipe. Use the following commands to do so

mkfifo 2way
ncat -l 8080 0<2way"" 1="" 80="" ncat="">2way

Now you will be able to send and receive data over the nc proxy.

Copying Files using nc/ncat
NC can also be used to copy the files from one system to another, though it is not recommended & mostly all systems have ssh/scp installed by default. But none the less if you have come across a system with no ssh/scp, you can also use nc as last ditch effort.

Start with machine on which data is to be received & start nc in listen mode and redirect the nc output to a file.

ncat -l  8080 > file.txt

Now on the machine from which the data is to be sent, run the following command

ncat 8080 --send-only < data.txt

Here, data.txt is the file that is to be sent. The --send-only option will close the connection once the file has been copied. If you do not use this option, then we will have to press ctrl+c to close the connection manually. We can also copy entire disk partitions using this method, but it should be done with caution, as there is no recovery option. If the transfer is interrupted, it must start again from scratch.
In this case ncat is "cat-ing" a file across a TCP connection to another server where the transferred data is redirected to a file name.

Create a backdoor via nc/ncat

The NC command can also be used to create a backdoor in your system. This technique is a method actually used by hackers. We should know how it works in order to secure our system. To create a backdoor, the command is.

ncat -l 10000 -e /bin/bash

The -e flag attaches a bash shell to port 10000.  Now a client can connect to port 10000 on the server at IP address and they will have complete access to the system through the bash shell when they run the following command.

ncat 1000

Port forwarding via nc/ncat

We can also use NC for port forwarding with the help of option -c .  The syntax for accomplishing port forwarding is

ncat -u -l  80 -c  'ncat -u -l 8080'

Now all the connections for port 80 will be forwarded to port 8080.

Set Connection timeouts

Listener mode in ncat will continue to run & would have to be terminated manually. But we can configure timeouts with option -w

ncat -w 10 8080

This will cause the connection to be terminated in 10 seconds, but it can only be used on the client side & not on the server side.

Force the server to stay up using the -k option in ncat
When the client disconnects from the server, after sometime the server also stops listening. However we can force the server to stay connected & continue listening to the port with the option -k . Run the following command

ncat -l -k 8080

Now the server will stay up, even if the connection from the client is broken.

13 March 2019

How to run logrotate for a specific log file

An extract from the web page http://www.thecave.info/execute-logrotate-command-manually/

Execute Logrotate Command Manually

I needed to rotate a log file that was filled with duplicate lines, and had filled the / directory. The syslog file was now 180GB in size. (a nouveau issue in Linux lite 4 caused this)   I knew that the compressed log file would be very small as the gigabytes of duplicate lines in syslog would compress to nothing. (eventually it was 11MB after compression)
The following extract/example is forcing the apache2 log file to rotate. I needed the syslog file to be rotated. The first job was to free up as much space as possible in order to allow the log rotate action to take place. This involved moving, or deleting all large files in my home directory, and deleting any archived log files that were large enough to make a difference.
I used the following command for syslog

  1. logrotate -vf /etc/logrotate.d/rsyslog

The extract from the previously mentioned web page where his problem is the apache log follows:-

Since most of my disk space was consumed by apache, I decided to execute logrotate command manually in linux and pass it the config of the logrotate apache . To do so, I used the following command:
  1. logrotate -vf /etc/logrotate.d/apache2.conf
The flags ‘-vf’ passed to the command are as follows:
  • -v verbose shows more information. useful to try detect any errors there may be with logrotate
  • -f force the rotation to occur even if it is not necessarily needed
And /etc/logrotate.d/apache2.conf is the location of my config file of for the apache2