My online notes – Section 0001

Note 1:

MongoDB Applied Design Patterns


Note 2:

1. List all properties and their values

static void Main(string[] args)
	string fileName = Path.Combine(Directory.GetCurrentDirectory(), "All Polished.mp4");
	ShellObject shellObject= ShellObject.FromParsingName(fileName);
	PropertyInfo[] propertyInfos = shellObject.Properties.System.GetType().GetProperties();
	foreach (var propertyInfo in propertyInfos)
		object value = propertyInfo.GetValue(shellObject.Properties.System, null);

		if (value is ShellProperty<int?>)
			var nullableIntValue = (value as ShellProperty<int?>).Value;
			Console.WriteLine($"{propertyInfo.Name} - {nullableIntValue}");
		else if (value is ShellProperty<ulong?>)
			var nullableLongValue =
				(value as ShellProperty<ulong?>).Value;
			Console.WriteLine($"{propertyInfo.Name} - {nullableLongValue}");
		else if (value is ShellProperty<string>)
			var stringValue =
				(value as ShellProperty<string>).Value;
			Console.WriteLine($"{propertyInfo.Name} - {stringValue}");
		else if (value is ShellProperty<object>)
			var objectValue =
				(value as ShellProperty<object>).Value;
			Console.WriteLine($"{propertyInfo.Name} - {objectValue}");
			Console.WriteLine($"{propertyInfo.Name} - Dummy value");



Note 3:

private void SetControlText(Control c, string strText)
//    if (InvokeRequired)  unnötig, denn du **weißt** ja dass Invoke Required ist
	this.BeginInvoke(()=> c.Text = strText);

Note 5: Ffmpeg Mp4 Join

ffmpeg -f concat -safe 0 -i “C:\Temp\mp4.txt” -c copy “C:\Temp\nhi.mp4”

Content of mp4.txt

file 'C:\Temp\WP_20170107_10_24_10_Pro.mp4'
file 'C:\Temp\WP_20170107_10_32_31_Pro.mp4'
file 'C:\Temp\WP_20170107_10_36_39_Pro.mp4'
file 'C:\Temp\WP_20170107_10_45_33_Pro.mp4'
file 'C:\Temp\WP_20170107_10_46_32_Pro.mp4'
file 'C:\Temp\WP_20170107_11_02_39_Pro.mp4'
file 'C:\Temp\WP_20170107_11_07_42_Pro.mp4'
file 'C:\Temp\WP_20170107_11_14_45_Pro.mp4'
file 'C:\Temp\WP_20170107_11_20_57_Pro.mp4'
file 'C:\Temp\WP_20170107_11_23_28_Pro.mp4'
file 'C:\Temp\WP_20170107_11_24_06_Pro.mp4'
file 'C:\Temp\WP_20170107_11_34_41_Pro.mp4'
file 'C:\Temp\WP_20170107_12_09_37_Pro.mp4'
file 'C:\Temp\WP_20170107_12_12_25_Pro.mp4'

Note 6: Update ubuntu

sudo apt-get update        # Fetches the list of available updates
sudo apt-get upgrade       # Strictly upgrades the current packages
sudo apt-get dist-upgrade  # Installs updates (new ones)
apt-get autoremove
sudo reboot

2) Adjust iptables (consider iptables -P INPUT DROP)

iptables -N syn
iptables -A syn -j ACCEPT
iptables -N SYN_CHECK
iptables -A SYN_CHECK -m recent --set --name SYN
iptables -A INPUT -p tcp --syn -d $IP -m state --state NEW -j SYN_CHECK

iptables -A SYN_CHECK -m recent --update --seconds 60 --hitcount 10 --name SYN -j LOG --log-prefix "FLOOD: "
iptables -A SYN_CHECK -m recent --update --seconds 60 --hitcount 10 --name SYN -j DROP

iptables -A SYN_CHECK -m recent --update --seconds 60 --hitcount 3 --name SYN -j syn
iptables -A INPUT -p tcp ! --syn -d $IP -m state --state ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp -s $IP -m state --state ESTABLISHED -j ACCEPT

To be sure blocking all violated IP (which used to cause SYN Flood) in 2 minutes; after 2 minutes check again if it does not attack anymore then let it in. Add this block

iptables -t mangle -N blockip
iptables -t mangle -A blockip -j DROP
iptables -t mangle -A PREROUTING -p tcp -d $IP -m recent --name SYN --update --seconds 120 -j blockip

$IP is the IP which is bounded on external interface of Linux server.

Note 5: Hash Strengthening
A modern server can calculate the MD5 hash of about 330MB every second. If your users have passwords which are lowercase, alphanumeric, and 6 characters long, you can try every single possible password of that size in around 40 seconds.

Note 6: Changing running account of SQL Server to enable backup to network drive
– Start –> Microsoft SQL Server 2008 –> Configuration Tools –> SQL Server Configurations Manager
– In new dialog choose SQL Server Service –> Right click on “SQL Server (SQLEXPRESS) –> Properties –> At “Log In” Tab choose “This account” –> under Account Name is network account name for example “edr\nguy” and under Password is windows login password –> Then click “Apply”.
– To backup database to network drive then using UNC Path for example “\\srvedrx\Transfer\Nguyen\test.bak”. Man will be asked for using this path although it can be not accessible, just click “Yes” to pass through.

Note 7: Top5 Freelancer platform in Germany
Top5 Freelancer platform in Germany

Note 8: Release und update DNS when site can not be found
ipconfig /registerdns –> ipconfig /displaydns –> ipconfig /flushdns –> ipconfig /displaydns

Note 9: Windows Installer Clean Up

Note 10: Authentication with .htaccess

Note 11: List all installed programms from command line
wmic product > list.txt (it takes time to finish).

Note 12: Windows Messages Enumeration

Note 13: Code to make a window behind all of windows and can not be minimized meaning that it will be visible with Win+M and Win+D

[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);

public frmMain()

	IntPtr hwndParent = FindWindow("progman", null);
	SetParent(this.Handle, hwndParent);

Note 14: Webmail for Bluehost when port 2095 is blocked
If you do not have access to because port 2095 is blocked on your network, you can alternately use using same login credential.

Note 15: SQL Injection at Order By Clause of MySQL (no chance to test, just take a note, see it later)
Case study: means “SELECT id,name,price FROM list ORDER BY 1”
returns a different result then this request:
Exploit: Get the first character of all tables char(substring(table_name,1,1)) from information_schema.tables limit 1)<=128))

Note 16: Check if program is started in Debug.Mode or Console.Mode

Debugger.IsAttached or Environment.CommandLine

Note 17: Important Add-Ins for Visual Studio

Note 18: WyBuild Patched Full Version

Note 19: Latest free version of .Net Reflector with Reflexil
.Net Reflector download

Note 20: Tool to control traffic in Network
– Which kind of traffic on network, source and destination of each kind as well as which traffic consumes most of bandwidth : NetFlow, SNMP, NBAR
– To limit bandwidth of limit (still allow traffic goes on network however its bandwidth should be limited) then use QoS on router: Queuing (CBWFQ), Policing, Shaping

Note 21: Differences between const, static, static readonly, readonly
– Use const when having a variable of a type, know at runtime (string literal, int, double, enums,…) that all instances or consumers of a class to have access to where the value should not change.
– Use static when having data that all instances or consumers of a class to have access to where the value can change.
– Use static readonly when having a variable of a type that not know at runtime (objects) that all instances or consumers of a class to have access to where the value should not change.
– Use readonly when having an instance level variable that know at the time of object creation that should not change.
One final note: a const field is static, but the inverse is not true.,_static_and_readonly

Notes 22: Generate Lotto numbers

var lotto = Enumerable.Range(1, 40)
                      .OrderBy(i => Guid.NewGuid())

Leave a Reply

Your email address will not be published. Required fields are marked *