Dre4m Shell
Server IP : 127.0.0.2  /  Your IP : 3.144.200.28
Web Server : Apache/2.4.18 (Ubuntu)
System :
User : www-data ( )
PHP Version : 7.0.33-0ubuntu0.16.04.16
Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/share/doc/netcat-openbsd/examples/contrib/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /usr/share/doc/netcat-openbsd/examples/contrib/ncmeter
#! /bin/bash

# script to measure the speed of netcat.
# start with one argument for usage information
#
# Tools that are used by this script are:
# nc, bc, wc, sed, awk
#
# Author: Karsten Priegnitz (koem@petoria.de)

NCPORT=23457
WAIT=1

# determine the programme's name
me=`echo $0 | sed 's+.*/++'`

# check number of arguments provided
if [ $# -ne 0 -a $# -ne 2 ]; then
	echo "Usage:"
	echo
	echo "  On the transmitter side:"
	echo "    $me <receivers ip-address> <amount of data>"
	echo 
	echo "  The <amount of data> is to be given in byte but you"
	echo "  also can supply M or K for MegaByte and KiloByte."
	echo "  Example: $me 10.1.1.3 20M"
	echo
	echo "  On the receiver side:"
	echo "    $me"
	echo 
	echo "  Start $me on the receiver side before starting it"
	echo "  on the transmitter side. Stop the receiver by pressing"
	echo "  and holding Ctrl-C."
	exit 1
fi

# are we the receiver?
if [ $# -eq 0 ]; then
	# yes, we are
	while true; do
		echo "waiting to receive data... (quit: press and hold Ctrl-C)"
		
		# wait for data and count bytes
		AMOUNT=`nc -v -w 120 -l -p $NCPORT | wc -c | awk '{print $1}'`
		
		# display amount of data received
		echo $AMOUNT byte of data received
		echo

		# sleep, so that the loop can be
		# interrupted by pressing Ctrl-C
		sleep 1
	done
fi

# we are the sender
echo "sending data..."

# calculate the amount of data to be sent
AMOUNT=`echo $2|sed s/[mM]/\*1048576/g | sed s/[kK]/\*1024/g | bc`

# send data and measure the time spent
TEMP=/tmp/$me.tx
( time -p dd if=/dev/zero bs=$AMOUNT count=1 2>/dev/null | nc -v -w $WAIT $1 $NCPORT ) 2>"$TEMP" || cat "$TEMP" 

# read the time needed
REAL=`grep "^real" "$TEMP" | awk '{print $2}'`
rm "$TEMP"
# subtract the wait times
DOUBLEWAIT=$(($WAIT * 2))
NEEDED=`echo $REAL - $DOUBLEWAIT|bc`

# calculate and print speed
BPS=`echo "scale=3;$AMOUNT / $NEEDED"|bc`
KBPS=`echo "scale=3;$AMOUNT / $NEEDED / 1024"|bc`
MBPS=`echo "scale=3;$AMOUNT / $NEEDED / 1048576"|bc`

echo "time needed:      ${NEEDED}s"
echo "byte per second:  $BPS"
echo "KByte per second: $KBPS"
echo "MByte per second: $MBPS"


Anon7 - 2022
AnonSec Team