<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://leo.leung.xyz/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=10.1.1.22</id>
	<title>Leo&#039;s Notes - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://leo.leung.xyz/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=10.1.1.22"/>
	<link rel="alternate" type="text/html" href="https://leo.leung.xyz/wiki/Special:Contributions/10.1.1.22"/>
	<updated>2026-10-06T10:32:22Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://leo.leung.xyz/wiki/index.php?title=Patching_a_binary_file_with_dd&amp;diff=1180</id>
		<title>Patching a binary file with dd</title>
		<link rel="alternate" type="text/html" href="https://leo.leung.xyz/wiki/index.php?title=Patching_a_binary_file_with_dd&amp;diff=1180"/>
		<updated>2015-06-09T15:11:31Z</updated>

		<summary type="html">&lt;p&gt;10.1.1.22: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Suppose I know an instruction in a particular offset after disassembling a binary file. You can use `dd` to change or patch a file like so.&lt;br /&gt;
&lt;br /&gt;
 dd if=nprobe bs=1 count=6 skip=$((0x1430C)) | xxd&lt;br /&gt;
 6+0 records in&lt;br /&gt;
 6+0 records out&lt;br /&gt;
 6 bytes (6 B) copied, 0.000122275 s, 49.1 kB/s&lt;br /&gt;
 0000000: 0f84 5401 0000                           ..T...&lt;br /&gt;
&lt;br /&gt;
I want to change the above from a jz to jnz like so:&lt;br /&gt;
 echo &amp;quot;0F 85 54 01 00 00&amp;quot; | udcli -64  -x&lt;br /&gt;
 0000000000000000 0f8554010000     jnz 0x15a&lt;br /&gt;
&lt;br /&gt;
Overwrite the byte (or bytes) like so:&lt;br /&gt;
 printf &#039;\x0f\x85&#039; | dd conv=notrunc of=nprobe bs=1 seek=$((0x1430C))&lt;br /&gt;
 2+0 records in&lt;br /&gt;
 2+0 records out&lt;br /&gt;
 2 bytes (2 B) copied, 0.00097866 s, 2.0 kB/s&lt;br /&gt;
&lt;br /&gt;
Verify:&lt;br /&gt;
 [root@localhost bin]# dd if=nprobe bs=1 count=6 skip=$((0x1430C)) | xxd&lt;br /&gt;
 6+0 records in&lt;br /&gt;
 6+0 records out&lt;br /&gt;
 6 bytes (6 B) copied, 0.000136555 s, 43.9 kB/s&lt;br /&gt;
 0000000: 0f85 5401 0000                           ..T...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To patch libnprobe so that it doesn&#039;t stop after 25000:&lt;br /&gt;
 printf &#039;\x0f\x85&#039; | dd conv=notrunc of=/usr/local/lib/libnprobe-7.1.150608.so bs=1 seek=$((0x47e97))&lt;br /&gt;
 dd if=/usr/local/lib/libnprobe-7.1.150608.so bs=1 count=6 skip=$((0x47e97)) | xxd&lt;br /&gt;
 0000000: 0f85 d700 0000    &lt;br /&gt;
&lt;br /&gt;
This will effectively disable the limitation by always jumping regardless of the count.&lt;/div&gt;</summary>
		<author><name>10.1.1.22</name></author>
	</entry>
	<entry>
		<id>https://leo.leung.xyz/wiki/index.php?title=Named&amp;diff=926</id>
		<title>Named</title>
		<link rel="alternate" type="text/html" href="https://leo.leung.xyz/wiki/index.php?title=Named&amp;diff=926"/>
		<updated>2015-03-24T04:57:19Z</updated>

		<summary type="html">&lt;p&gt;10.1.1.22: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Enable Query Logging ==&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;rndc&amp;lt;/code&amp;gt; to enable query logging:&lt;br /&gt;
 rndc querylog on&lt;br /&gt;
&lt;br /&gt;
Lookups will then be dumped into &amp;lt;code&amp;gt;/var/log/messages&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To see whether rndc querylog is enabled, run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line start=&amp;quot;1&amp;quot; highlight=&amp;quot;1&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
rndc status&lt;br /&gt;
 ...&lt;br /&gt;
 query logging is ON&lt;br /&gt;
 ...&lt;br /&gt;
 server is up and running&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To enable logging by default, edit /etc/named.conf with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line start=&amp;quot;1&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
logging {&lt;br /&gt;
        channel &amp;quot;querylog&amp;quot; {&lt;br /&gt;
                file &amp;quot;/var/log/named-query.log&amp;quot;;&lt;br /&gt;
                print-time yes;&lt;br /&gt;
        };&lt;br /&gt;
        category queries { querylog; };&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Disable IPv6 Lookups ==&lt;br /&gt;
&lt;br /&gt;
If you have querylog enabled, you may see lots of messages like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; line start=&amp;quot;1&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
May  5 12:14:44 linux named[2492]: error (network unreachable) resolving &#039;ns2.google.com/A/IN&#039;: 2001:503:231d::2:30#53&lt;br /&gt;
May  5 12:14:44 linux named[2492]: error (network unreachable) resolving &#039;ns2.google.com/AAAA/IN&#039;: 2001:503:231d::2:30#53&lt;br /&gt;
May  5 12:14:44 linux named[2492]: error (network unreachable) resolving &#039;ns3.google.com/A/IN&#039;: 2001:503:231d::2:30#53&lt;br /&gt;
May  5 12:14:44 linux named[2492]: error (network unreachable) resolving &#039;ns4.google.com/A/IN&#039;: 2001:503:231d::2:30#53&lt;br /&gt;
May  5 12:14:44 linux named[2492]: error (network unreachable) resolving &#039;ns3.google.com/AAAA/IN&#039;: 2001:503:231d::2:30#53&lt;br /&gt;
May  5 12:14:44 linux named[2492]: error (network unreachable) resolving &#039;ns1.google.com/A/IN&#039;: 2001:503:231d::2:30#53&lt;br /&gt;
May  5 12:14:57 linux named[2492]: error (network unreachable) resolving &#039;ns2.p42.dynect.net/A/IN&#039;: 2001:500:3::42#53&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since I don&#039;t have IPv6 on my network, it&#039;s obvious why I can&#039;t lookup IPv6 addresses. To fix this, do:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line start=&amp;quot;1&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
vi /etc/sysconfig/named&lt;br /&gt;
 OPTIONS=&amp;quot;-4&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating &#039;zones&#039; via Views ==&lt;br /&gt;
&lt;br /&gt;
If you want to provide a set of IP addresses or subnets with a specific set of zones, use &amp;lt;code&amp;gt;view&amp;lt;/code&amp;gt;s to accomplish this. The basic syntax for a view is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
view &amp;quot;NetworkAB&amp;quot; {&lt;br /&gt;
	match-clients { subnetA; subnetB; };&lt;br /&gt;
&lt;br /&gt;
	# Zones go here&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You may also use &amp;lt;code&amp;gt;acl&amp;lt;/code&amp;gt; to group multiple subnets into one &#039;client&#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
acl subnetAB { subnetA; subnetB; };&lt;br /&gt;
&lt;br /&gt;
view &amp;quot;NetworkAB&amp;quot; {&lt;br /&gt;
	match-clients { subnetAB; };&lt;br /&gt;
&lt;br /&gt;
	# Zones go here&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To have one specific IP address inside another view instead, use the &amp;lt;code&amp;gt;!&amp;lt;/code&amp;gt; operator in either the ACL definition list or the &amp;lt;code&amp;gt;match-clients&amp;lt;/code&amp;gt; list.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
acl subnetAB { ! leosIPInSubnetA/32; subnetA; subnetB; };&lt;br /&gt;
acl subnetLeo { leosIPInSubnetA/32; };&lt;br /&gt;
&lt;br /&gt;
view &amp;quot;NetworkAB&amp;quot; {&lt;br /&gt;
	match-clients { subnetAB; };&lt;br /&gt;
&lt;br /&gt;
	# Zones go here&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
view &amp;quot;LeosView&amp;quot; {&lt;br /&gt;
	match-clients { subnetLeo; };&lt;br /&gt;
&lt;br /&gt;
	# Zones only Leo can see can go here&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Linux]]&lt;br /&gt;
[[Category:Services]]&lt;/div&gt;</summary>
		<author><name>10.1.1.22</name></author>
	</entry>
	<entry>
		<id>https://leo.leung.xyz/wiki/index.php?title=Webcam&amp;diff=925</id>
		<title>Webcam</title>
		<link rel="alternate" type="text/html" href="https://leo.leung.xyz/wiki/index.php?title=Webcam&amp;diff=925"/>
		<updated>2015-03-24T03:07:57Z</updated>

		<summary type="html">&lt;p&gt;10.1.1.22: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Linux ==&lt;br /&gt;
To get a webcam working for Linux, ensure that it&#039;s supported. Newer webcams tend to have support though cheaper non-HD webcams from China might not. You should see a &amp;lt;code&amp;gt;/dev/video0&amp;lt;/code&amp;gt; device when the webcam is plugged into the computer. If not, check &amp;lt;code&amp;gt;dmesg&amp;lt;/code&amp;gt; and see if the USB device is being detected. &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; should also list it.&lt;br /&gt;
&lt;br /&gt;
The default permissions set to &amp;lt;code&amp;gt;/dev/video0&amp;lt;/code&amp;gt; is set by udev. If you need to change the device permissions (say making it world read/writable), you will need to create a udev rule by creating a new file in &amp;lt;code&amp;gt;/etc/udev/rules.d/&amp;lt;/code&amp;gt; with the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
SUBSYSTEM==&amp;quot;video4linux&amp;quot;, BUS==&amp;quot;usb&amp;quot;, SYSFS{idVendor}==&amp;quot;045e&amp;quot;, SYSFS{idProduct}==&amp;quot;0761&amp;quot;, NAME=&amp;quot;video0&amp;quot;, MODE=&amp;quot;0666&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Vendor ID and product ID must match the values from &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt;. For the example above (a Microsoft LifeCam VX-2000):&lt;br /&gt;
 # lsusb&lt;br /&gt;
 Bus 001 Device 005: ID 045e:0761 Microsoft Corp.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To capture images, use any one of the following utilities:&lt;br /&gt;
* fswebcam&lt;br /&gt;
* uvccapture&lt;br /&gt;
&lt;br /&gt;
You may configure the webcam settings using &amp;lt;code&amp;gt;v4l-utils&amp;lt;/code&amp;gt;. See http://www.techytalk.info/webcam-settings-control-ubuntu-fedora-linux-operating-system-cli/&lt;br /&gt;
&lt;br /&gt;
=== fswebcam ===&lt;br /&gt;
 fswebcam -r 640x480 --jpeg 85 -D 1 web-cam-shot.jpg&lt;br /&gt;
&lt;br /&gt;
==== Dumping fswebcam images via HTTP ====&lt;br /&gt;
You can make a quick an dirty wrapper around the command above so that it can be viewed via the web.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
system(&amp;quot;fswebcam -r 640x480 --jpeg 85 -D 1 /tmp/out.jpg &amp;gt; /dev/null&amp;quot;);&lt;br /&gt;
header(&amp;quot;Content-Type: image/jpeg&amp;quot;);&lt;br /&gt;
echo file_get_contents(&amp;quot;/tmp/out.jpg&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== uvccapture ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Linux]]&lt;/div&gt;</summary>
		<author><name>10.1.1.22</name></author>
	</entry>
</feed>