<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://simoneaonzo.it/feed.xml" rel="self" type="application/atom+xml" /><link href="https://simoneaonzo.it/" rel="alternate" type="text/html" /><updated>2026-03-09T10:53:03+01:00</updated><id>https://simoneaonzo.it/feed.xml</id><title type="html">Simone Aonzo aka Packmad</title><subtitle>This is the personal (unpretentious) website of Simone Aonzo.  Here you will find stuff about: cybersecurity, hacking, malware, Android...</subtitle><author><name>Simone Aonzo, PhD</name><email>simone.aonzo@gmail.com</email></author><entry><title type="html">We are looking for PhD students!</title><link href="https://simoneaonzo.it/hiring-eurecom/" rel="alternate" type="text/html" title="We are looking for PhD students!" /><published>2022-05-05T00:00:00+02:00</published><updated>2022-05-05T00:00:00+02:00</updated><id>https://simoneaonzo.it/hiring-eurecom</id><content type="html" xml:base="https://simoneaonzo.it/hiring-eurecom/"><![CDATA[<p>In April 2022, I was hired as an Assistant Professor at <a href="https://www.eurecom.fr/">Eurecom</a>. 
My main research topics are system security and privacy, focusing on malware analysis (Android and Windows).</p>

<p>We – the <a href="https://s3.eurecom.fr/">s3 group</a> – have several open positions to be filled, and we are looking for brave students who feel up to attempting the Ph.D. adventure!</p>

<p>I have made a couple of <a href="https://docs.google.com/presentation/d/1gx7d78Ww-43yHISqrBN-dKIYrmuSviBoyQBdZXj1e8M/edit?usp=sharing">slides</a> about my perspective on the Ph.D.</p>

<p>Finally, the <a href="https://docs.google.com/presentation/d/1EJh5LfeYEGgBTI0Y8YTYCvmnFlXhKKxrsHXpPoOBRyI/edit?usp=sharing">slides</a> on who we are and what we do in our research group.</p>

<p>You can write me at the email address: simone.aonzo(AT)eurecom.fr</p>]]></content><author><name>Simone Aonzo, PhD</name><email>simone.aonzo@gmail.com</email></author><category term="ad" /><summary type="html"><![CDATA[In April 2022, I was hired as an Assistant Professor at Eurecom. My main research topics are system security and privacy, focusing on malware analysis (Android and Windows).]]></summary></entry><entry><title type="html">Update on the adoption of the Digital Asset Links protocol</title><link href="https://simoneaonzo.it/dal-adoption-update/" rel="alternate" type="text/html" title="Update on the adoption of the Digital Asset Links protocol" /><published>2022-01-13T00:00:00+01:00</published><updated>2022-01-13T00:00:00+01:00</updated><id>https://simoneaonzo.it/dal-adoption-update</id><content type="html" xml:base="https://simoneaonzo.it/dal-adoption-update/"><![CDATA[<p>I have repeated a measurement we did in “Phishing Attacks on Modern Android”; see my <a href="/publications/">publications</a> page. In addition to the paper, you will also find the video.</p>

<p>We were interested in determining how ready the ecosystem is regarding the information required to build a secure app-to-web mapping. 
Given that the current standard is the <a href="https://developers.google.com/digital-asset-links">Digital Asset Links</a> (DAL from now on) protocol, we set to analyze the adoption rate by querying a dataset of domain names for their related <code class="language-plaintext highlighter-rouge">assetlinks.json</code> DAL file.</p>

<p>As a dataset, we considered all domain names from all mapping we extracted from the password managers we have inspected. 
Note that since they are extracted from password managers, it is very likely that these domain names host at least one page with a login form, thus making them relevant for this observation. 
In our article published in 2018, we were able to query 8,821 unique websites, but unfortunately, I did not save the complete list with all the domains, so I repeated the measurement on these.</p>

<p>Today (2022-01-13), I have successfully queried <strong>5,506</strong> unique websites for the <code class="language-plaintext highlighter-rouge">/.well-known/assetlinks.json</code> file. Namely, I have excluded all those who returned a status code other than 404 or 200. 
I found that <strong>24%</strong> (1,330/5,506) of them host an associated DAL file, and <strong>23%</strong> (1,265/5,506) specify an Android app in accordance with Google documentation. 
Four years ago, such percentages were 8% and 2%, respectively.</p>

<p>I am glad to see an increase, but I was hoping for more. 
I think DAL is vitally important to the Android ecosystem: not only does it allow to map the package name to websites securely, but it also provides for specifying the app signature, which is crucial for thwarting attacks and identifying malware.</p>]]></content><author><name>Simone Aonzo, PhD</name><email>simone.aonzo@gmail.com</email></author><category term="phishing" /><category term="web" /><summary type="html"><![CDATA[I have repeated a measurement we did in “Phishing Attacks on Modern Android”; see my publications page. In addition to the paper, you will also find the video.]]></summary></entry><entry><title type="html">Dear Windows Defender, please tell me where I can drop my malicious code</title><link href="https://simoneaonzo.it/win-defender-exclusion-path/" rel="alternate" type="text/html" title="Dear Windows Defender, please tell me where I can drop my malicious code" /><published>2020-03-24T00:00:00+01:00</published><updated>2020-03-24T00:00:00+01:00</updated><id>https://simoneaonzo.it/win-defender-exclusion-path</id><content type="html" xml:base="https://simoneaonzo.it/win-defender-exclusion-path/"><![CDATA[<p><a href="https://medium.com/@simone.aonzo/dear-windows-defender-please-tell-me-where-i-can-drop-my-malicious-code-9c4f50f417a1">Dear Windows Defender, please tell me where I can drop my malicious code.</a> @ <a href="https://medium.com/@simone.aonzo">medium.com</a></p>]]></content><author><name>Simone Aonzo, PhD</name><email>simone.aonzo@gmail.com</email></author><category term="malware" /><summary type="html"><![CDATA[Dear Windows Defender, please tell me where I can drop my malicious code. @ medium.com]]></summary></entry><entry><title type="html">The importance of Data Execution Prevention in malware analysis</title><link href="https://simoneaonzo.it/importance-of-dep/" rel="alternate" type="text/html" title="The importance of Data Execution Prevention in malware analysis" /><published>2019-08-02T00:00:00+02:00</published><updated>2019-08-02T00:00:00+02:00</updated><id>https://simoneaonzo.it/importance-of-dep</id><content type="html" xml:base="https://simoneaonzo.it/importance-of-dep/"><![CDATA[<p><a href="https://medium.com/@simone.aonzo/the-importance-of-data-execution-prevention-in-malware-analysis-fd29d0c9e03e">The importance of Data Execution Prevention in malware analysis</a> @ <a href="https://medium.com/@simone.aonzo">medium.com</a></p>]]></content><author><name>Simone Aonzo, PhD</name><email>simone.aonzo@gmail.com</email></author><category term="malware" /><summary type="html"><![CDATA[The importance of Data Execution Prevention in malware analysis @ medium.com]]></summary></entry><entry><title type="html">Enable core dumps (for every user) in Raspbian</title><link href="https://simoneaonzo.it/enable-core-dumps-raspbian/" rel="alternate" type="text/html" title="Enable core dumps (for every user) in Raspbian" /><published>2018-08-16T00:00:00+02:00</published><updated>2018-08-16T00:00:00+02:00</updated><id>https://simoneaonzo.it/enable-core-dumps-raspbian</id><content type="html" xml:base="https://simoneaonzo.it/enable-core-dumps-raspbian/"><![CDATA[<p>Create file:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>/etc/sysctl.d/core.conf:
</code></pre></div></div>

<p>With this content:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>kernel.core_pattern = /var/lib/coredumps/core-%e-sig%s-user%u-group%g-pid%p-time%t
kernel.core_uses_pid = 1
fs.suid_dumpable = 2
</code></pre></div></div>

<p>Create such a folder, and set permissions:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mkdir /var/lib/coredumps/
chmod 777 /var/lib/coredumps/
</code></pre></div></div>

<p>Edit file:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>/etc/security/limits.conf
</code></pre></div></div>

<p>Add this content:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>*  soft  core  unlimited
</code></pre></div></div>

<p>Logoff and logon, then:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ulimit -c unlimited
</code></pre></div></div>

<p>Check if it worked:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ ulimit -a
core file size          (blocks, -c) unlimited
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 7345
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 7345
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
</code></pre></div></div>

<p>Memento gdb core dump analysis:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>gdb &lt;executable&gt; &lt;core_dump_file&gt;
</code></pre></div></div>

<p>Install gdb 8.1</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>apt install texinfo python2.7-dev python3-dev
wget http://ftp.gnu.org/gnu/gdb/gdb-8.1.1.tar.xz
tar xf gdb-8.1.1.tar.xz
cd gdb-8.1/
./configure --with-python &amp;&amp; make &amp;&amp; make install
</code></pre></div></div>]]></content><author><name>Simone Aonzo, PhD</name><email>simone.aonzo@gmail.com</email></author><category term="core dumps" /><category term="raspbian" /><summary type="html"><![CDATA[Create file: /etc/sysctl.d/core.conf:]]></summary></entry><entry><title type="html">Debug Android smali code (without repackaging)</title><link href="https://simoneaonzo.it/debug-smali/" rel="alternate" type="text/html" title="Debug Android smali code (without repackaging)" /><published>2018-01-18T00:00:00+01:00</published><updated>2018-01-18T00:00:00+01:00</updated><id>https://simoneaonzo.it/debug-smali</id><content type="html" xml:base="https://simoneaonzo.it/debug-smali/"><![CDATA[<p>Download an <a href="https://developer.android.com/studio/index.html">Android Studio</a> version greater than 3, because Google added a very useful feature: <a href="https://developer.android.com/studio/debug/apk-debugger.html">Profile and Debug Pre-built APKs</a>.</p>

<p>This new feature needs to attach the Java source code for setting breakpoints, but <a href="https://github.com/JesusFreke/smali/wiki/smalidea">smalidea</a> allow us to do it directly on <a href="https://github.com/JesusFreke/smali/wiki">smali code</a>!</p>

<p><a href="https://bitbucket.org/JesusFreke/smali/downloads/">Download</a> the latest version of smalidea, then install it from Android Studio (from now on AS):</p>

<ul>
  <li>File -&gt; Settings -&gt; Plugins -&gt; Install plugin from disk…</li>
</ul>

<p>Restart AS and open your apk:</p>

<ul>
  <li>File -&gt; Profile or debug APK…</li>
</ul>

<p>Now, on your emulator (I didn’t test it on a real device, but surely you need root permissions) choose your target APK:</p>

<ul>
  <li>Settings -&gt; Developer options -&gt; Select debug app
    <ul>
      <li>Flag “Wait for debugger”</li>
    </ul>
  </li>
</ul>

<p>Start your app!</p>

<p>Let’s get back to AS. Browse the class/method that you want to debug using the left panel and set the breakpoints.</p>

<ul>
  <li>Tools -&gt; Android -&gt; Android Device Monitor
    <ul>
      <li>If you see nothing in the  Android Device Monitor panel:
        <ul>
          <li>Window -&gt; Rest perspective</li>
        </ul>
      </li>
    </ul>
  </li>
</ul>

<p>In the <strong>Devices</strong> panel you will see a three column matrix:</p>

<ol>
  <li>package name</li>
  <li>pid</li>
  <li>port</li>
</ol>

<p>Click your app and take care that in the last column is confirmed that the port on your emulator is mapped with the local 8700 port, as shown in the image.</p>

<p><img src="https://packmad.github.io/images/postimgs/adm.png" alt="Android Device Monitor screenshot" /></p>

<p>Last step:</p>

<ul>
  <li>Run -&gt; Edit configurations
    <ul>
      <li>Click on the green + button</li>
      <li>Choose “Remote”
        <ul>
          <li>Port: 8700</li>
        </ul>
      </li>
    </ul>
  </li>
</ul>

<p>Click the debug icon and… there you are!</p>

<p>If you want to explore the content of a register you need to add a new watch (shortcut: Ins) and type the name of the register.</p>

<p>Everything else works like a normal debug session.</p>]]></content><author><name>Simone Aonzo, PhD</name><email>simone.aonzo@gmail.com</email></author><category term="android" /><category term="debug" /><category term="smali" /><summary type="html"><![CDATA[Download an Android Studio version greater than 3, because Google added a very useful feature: Profile and Debug Pre-built APKs.]]></summary></entry><entry><title type="html">Debug Android native code with gdb</title><link href="https://simoneaonzo.it/gdb-android/" rel="alternate" type="text/html" title="Debug Android native code with gdb" /><published>2017-08-31T21:34:30+02:00</published><updated>2017-08-31T21:34:30+02:00</updated><id>https://simoneaonzo.it/gdb-android</id><content type="html" xml:base="https://simoneaonzo.it/gdb-android/"><![CDATA[<p>Requisites:</p>
<ul>
  <li>Root permissions needed</li>
  <li>Android sdk with ndk</li>
  <li><a href="https://github.com/hugsy/gef">GDB Enhanced Features</a></li>
</ul>

<p>In this example the packname of the app is: <code class="language-plaintext highlighter-rouge">com.example.nativetest</code></p>

<p>Find the right gdb executable for your architecture:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ find ~/Android/Sdk/ -type f -name "gdbserver"
~/Android/Sdk/ndk-bundle/prebuilt/android-mips/gdbserver/gdbserver
~/Android/Sdk/ndk-bundle/prebuilt/android-x86/gdbserver/gdbserver
~/Android/Sdk/ndk-bundle/prebuilt/android-mips64/gdbserver/gdbserver
~/Android/Sdk/ndk-bundle/prebuilt/android-arm64/gdbserver/gdbserver
~/Android/Sdk/ndk-bundle/prebuilt/android-arm/gdbserver/gdbserver
~/Android/Sdk/ndk-bundle/prebuilt/android-x86_64/gdbserver/gdbserver
</code></pre></div></div>

<p>Copy the gdb server executable (w.r.t. your target architecture, in this example I am using the <em>arm</em> version) in a temporary folder and give to it full permissions:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>adb push ~/Android/Sdk/ndk-bundle/prebuilt/android-arm/gdbserver/gdbserver /data/local/tmp/
adb shell "chmod 777 /data/local/tmp/gdbserver"
adb shell "ls -l /data/local/tmp/gdbserver"
</code></pre></div></div>

<p>In order to find debug information/symbols you’ll need all libraries in  your device/emulator to be copied to your PC. 
Gdb will need them later on.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mkdir -p ~/dbgtmp/
adb pull /system/lib ~/dbgtmp/
ls -l ~/dbgtmp/lib/
</code></pre></div></div>

<p>You must also copy the native library <code class="language-plaintext highlighter-rouge">&lt;NATIVELIBDBG&gt;</code> (contained in your target apk <code class="language-plaintext highlighter-rouge">&lt;TARGETAPK&gt;</code>) you want to debug!</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mkdir tmp
unzip &lt;TARGETAPK&gt; -d tmp
cp tmp/lib/&lt;ARCH&gt;/&lt;NATIVELIBDBG&gt; ~/dbgtmp/lib
</code></pre></div></div>

<p>Before continuing forward the port that will be used for the communication between gdb and gdbserver:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>adb forward tcp:1337 tcp:1337
</code></pre></div></div>

<p>Launch the app, but do not trigger the execution of the native code.
Become root, disable SELinux and attach gdb to the running process of your app with packagename <code class="language-plaintext highlighter-rouge">&lt;PACKAGENAME&gt;</code>):</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>adb shell
# su
# setenforce 0
# /data/local/tmp/gdbserver :1337 --attach $(ps | grep &lt;PACKAGENAME&gt; | awk '{print $2}')
</code></pre></div></div>

<p>Start gdb and be careful: use the Android-SDK executable!</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>~/Android/Sdk/ndk-bundle/prebuilt/linux-x86_64/bin/gdb
</code></pre></div></div>

<p>Connect to the gdbserver instance, specify the directories where gdb must search for the symbols of shared libraries.
Then check if the operation has been successfully completed.
Lastly, you can tabbing the function name that you want to debug (usually you are looking for some <code class="language-plaintext highlighter-rouge">Java_*</code> entrypoint), and then you can set a break point on such function:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>gef&gt; gef-remote :1337
gef&gt; set solib-search-path ~/dbgtmp/lib
gef&gt; info sharedlibrary
gef&gt; break Java_&lt;TAB&gt;
gef&gt; continue
</code></pre></div></div>

<p>Now you can interact with your app and trigger the execution of the native function.
I wish you happy debugging!</p>]]></content><author><name>Simone Aonzo, PhD</name><email>simone.aonzo@gmail.com</email></author><category term="android" /><category term="gdb" /><summary type="html"><![CDATA[Requisites: Root permissions needed Android sdk with ndk GDB Enhanced Features]]></summary></entry><entry><title type="html">Real vs Effective UID/GUID</title><link href="https://simoneaonzo.it/real-vs-effective/" rel="alternate" type="text/html" title="Real vs Effective UID/GUID" /><published>2017-01-17T00:00:00+01:00</published><updated>2017-01-17T00:00:00+01:00</updated><id>https://simoneaonzo.it/real-vs-effective</id><content type="html" xml:base="https://simoneaonzo.it/real-vs-effective/"><![CDATA[<h3 id="background">Background</h3>

<p>In *nix systems the <strong>User Id Number</strong> (UID) and the <strong>Group Id Number</strong> (GID) are integers used for identifying uniquely users and groups. 
Take a look at <a href="https://www.cyberciti.biz/faq/understanding-etcpasswd-file-format/"><em>/etc/passwd</em></a> and <a href="https://www.cyberciti.biz/faq/understanding-etcgroup-file/"><em>/etc/group</em></a> files (follow the links for more details about these files):</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>simo@xps:~$ cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
[...]
simo:x:1000:1000:simo,,,:/home/simo:/bin/bash
debian-tor:x:121:133::/var/lib/tor:/bin/false
</code></pre></div></div>

<p>We can infer:</p>

<table>
  <thead>
    <tr>
      <th><strong>User</strong></th>
      <th><strong>UID</strong></th>
      <th><strong>GID (primary)</strong></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>root</td>
      <td>0</td>
      <td>0</td>
    </tr>
    <tr>
      <td>simo</td>
      <td>1000</td>
      <td>1000</td>
    </tr>
    <tr>
      <td>debian-tor</td>
      <td>121</td>
      <td>133</td>
    </tr>
  </tbody>
</table>

<p>Their counterparts in the group file:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>simo@xps:~$ cat /etc/group
root:x:0:
[...]
simo:x:1000:
vboxusers:x:130:simo
debian-tor:x:133:
</code></pre></div></div>

<p>Moreover you can see that the user <em>“simo”</em> belong also to the <em>“vboxusers”</em> group.</p>

<h3 id="real-ugid-vs-effective-ugid">Real (U|G)ID vs Effective (U|G)ID</h3>

<p>Every running process has at least 4 ID numbers associated with it:</p>

<ul>
  <li>the <strong>Real UID</strong> (RUID) identifies the user who launched the process.</li>
  <li>the <strong>Real GID</strong> (RGID) identifies the primary group of the user that launched the process.</li>
  <li>the <strong>Effective UID</strong> (EUID) and the <strong>Effective GID</strong> (EGID) are used to determine what resources the process can access.</li>
</ul>

<p>These information can be found programmatically:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>simo@xps:~/example$ cat ids.c
#include
#include
int main()
{
 uid_t real_uid = getuid();
 uid_t effect_uid = geteuid();
 gid_t real_gid = getgid();
 gid_t effect_gid = getegid();
 printf("ruid=%d euid=%d\n", real_uid, effect_uid);
 printf("rgid=%d egid=%d\n", real_gid, effect_gid);
}
</code></pre></div></div>

<p>Usually the IDs have the same value when you run a program, but sometimes happens that an operating system needs to run programs with temporarily elevated privileges in order to perform a specific task.</p>

<p>The <strong>setuid</strong> (set user id) is a permission bit, that <strong>allows the users to exec a program with the permissions of its owner.</strong> The <strong>setgid</strong> (set group id) is a bit that <strong>allows the user to exec a program with the permissions of the group owner.</strong></p>

<p>The s(u|g)id bit on executables only changes the E(U|G)ID the executable will run as, and not the real(U|G)ID. 
Let’s take a closer look:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ gcc -Wall ids.c -o example
$ sudo chown root.root example
$ ls -l
total 16
-rw-rw-r-- 1 simo simo 294  gen 17 16:21 ids.c
-rwxrwxr-x 1 root root 8816 gen 17 16:28 example
$ ./example
ruid=1000 euid=1000
rgid=1000 egid=1000
$ sudo chmod 6771 example
$ ls -l
total 16
-rw-rw-r-- 1 simo simo 294 gen 17 16:21 ids.c
-rwsrws--x 1 root root 8816 gen 17 16:29 example
$ ./example
ruid=1000 euid=0
rgid=1000 egid=0
</code></pre></div></div>

<ol>
  <li>I compiled the example;</li>
  <li>I changed the owner and the group from “simo” to “root”;</li>
  <li>I ran the program and I got the same ids;</li>
  <li>I set the setuid and the setgid, pay attention to the <code class="language-plaintext highlighter-rouge">s</code> here
    <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>-rwsrws--x 1 root root 8816 gen 17 16:29 example
</code></pre></div>    </div>
  </li>
  <li>Ids changes accordingly!</li>
</ol>

<p><strong>Hint</strong>: in addition to the restriction on <code class="language-plaintext highlighter-rouge">s(u|g)id</code> interpreted scripts (any executable text file beginning with “#!”), some shells (like bash) as an extra safety measure will set the EUID back to the RUID; in this case, you will need to wrap the call to the script within a C program and setuid(…) before executing the script.</p>]]></content><author><name>Simone Aonzo, PhD</name><email>simone.aonzo@gmail.com</email></author><category term="linux" /><category term="permissions" /><summary type="html"><![CDATA[Background]]></summary></entry><entry><title type="html">How many bits are there in a Byte?</title><link href="https://simoneaonzo.it/bits-in-byte/" rel="alternate" type="text/html" title="How many bits are there in a Byte?" /><published>2016-10-02T00:00:00+02:00</published><updated>2016-10-02T00:00:00+02:00</updated><id>https://simoneaonzo.it/bits-in-byte</id><content type="html" xml:base="https://simoneaonzo.it/bits-in-byte/"><![CDATA[<p>8. Yes, sometimes… whereas the bit is <a href="https://en.wikipedia.org/wiki/Bit">well defined</a>:</p>

<ul>
  <li>a bit is the basic unit of information in computing and digital communications;</li>
  <li>a bit can have only one of two values, and may, therefore, be physically implemented with a two-state device;</li>
  <li>the values of a bit are most commonly represented as either a 0 or 1.</li>
</ul>

<p>Instead, the size of one Byte, as described <a href="http://catb.org/~esr/jargon/html/B/byte.html">in the Jargon file</a>, is architecture-dependent and, more precisely, is a unit of memory or data equal to the amount used to represent one character. In the same link, or in <a href="https://en.wikipedia.org/wiki/Byte">the wiki page</a>, is also explained that there was architecture with 6, 7, or 9 bits… or they operated on bit fields <a href="https://en.wikipedia.org/wiki/PDP-10">from 1 to 36</a>!</p>

<p>Obviously, it is extremely convenient that, from the architecture/hardware perspective, a Byte is the smallest addressable unit of memory: for this reason every operation that involves data exchange between the CPU and the RAM is made with Byte sizes or its multiples (Word, Double Word, and Quad Word).</p>

<p>We agree that the popularity of major commercial computing architectures has aided in the ubiquitous acceptance that <em>a Byte is 8-bit size</em>, but we must remember that it is only a de facto standard. You can see it by yourself.</p>

<p>Compile this C code with gcc on your Linux machine:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>#include&lt;stdio.h&gt;
#include&lt;limits.h&gt;

int main() {
    printf("%zu Byte = %d bits\n", sizeof(char), __CHAR_BIT__);
    printf("%lu Byte = %lu bits\n", sizeof(int), sizeof(int)*__CHAR_BIT__);
    return 0;
}
</code></pre></div></div>

<p>And run it:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ gcc test.c
$ ./a.out
1 Byte = 8 bits
4 Byte = 32 bits

</code></pre></div></div>]]></content><author><name>Simone Aonzo, PhD</name><email>simone.aonzo@gmail.com</email></author><category term="bit" /><category term="byte" /><summary type="html"><![CDATA[8. Yes, sometimes… whereas the bit is well defined:]]></summary></entry></feed>