{"id":198,"date":"2019-10-05T15:25:29","date_gmt":"2019-10-05T15:25:29","guid":{"rendered":"http:\/\/tonysbit.blog\/?p=198"},"modified":"2019-10-05T15:25:29","modified_gmt":"2019-10-05T15:25:29","slug":"spoofing-udp-traffic-with-logstash","status":"publish","type":"post","link":"https:\/\/tonysbit.blog\/?p=198","title":{"rendered":"Spoofing UDP Traffic with Logstash"},"content":{"rendered":"\n
Logs are usually sent via UDP traffic and most commonly available as a syslog message:<\/p>\n
These logs in many products (especially SIEM – Security information and event management) have their sources identified using the source-IP of the packet instead of the content of the message (Often the content of the log does not contain source identification information, this is a result of poor logging design), as such in more complex topologies with log caching or staged log propagation, the source of the logs cannot differentiated by the final system.<\/p>\n<\/div>\n\n\n\n This may not matter in a environment where the cache is only caching logs from a single device, however if the cache is centralizing logs from multiple sources, it makes it impossible for the SIEM to differentiate device sources for the logs impacting the functionality available.<\/p>\n<\/div>\n\n\n\n This has been a ticket<\/a> since 04\/05\/2017.<\/p>\n<\/div>\n\n\n\n Elasticsearch is commonly used as a centralization point for logs due to its high ingestion capability as well as the extensive libraries of plugins that can be used for collecting, transforming and forwarding almost all types of data. This is especially important for Service Providers who may have a responsibility such as to both store a copy of logs as well as send a copy to customers for their usage in their own SIEM solutions.<\/p>\n<\/div>\n\n\n\n The default UDP Logstash output plugin does not allow for spoofing the source device (IP Address, Port and MAC). I have written a new Logstash output to enable this behavior. The plugin is able to, on every individual message spoof the Source IP, Source Port and Source MAC Address of the packet. To use the plugin you need to specify additional information about the target device:<\/p>\n The plugin uses the jnetpcap library and therefore requires a number of pre-requisites on the host to be completed:<\/p>\n It is possible to run the library on different operating systems, I have tested on Ubuntu 18.04. For instructions on how to run it on other operating systems, there are notes in the Release Notes<\/a> of the library.<\/p>\n After deploying a new Ubuntu Server with the default Logstash installation, complete the following steps:<\/p>\n Note: Using Centos, the package is only available via the RHEL optional channel<\/a>.<\/p>\n Note: If you are running logstash as a service, the default permissions for the logstash user are not sufficient, run the service as root (If anyone knows the exact permissions to harden please DM me).<\/p>\n This can be done by editing \/etc\/systemd\/system\/logstash.service if you are using systemctl.<\/p>\n You can download the source code<\/a> and build the code yourself. Alternatively you can download the gem directly from here<\/a>.<\/p>\n Note: Remember to replace the values marked to be replaced<\/p>\n Note: You may need to install tcpdump<\/p>\n Note: Be patient, Logstash is very slow to start up<\/p>\n On the target system you are capturing traffic from you should see the source of the packet is coming from 3.3.3.3! Congratulations on spoofing your first message.<\/p>\n<\/div>\n\n\n\n In this post I have demonstrated how you can use the new Logstash Plugin to spoof traffic, as this can be done using event based data this plugin can be used to support many exotic deployment topologies that are SIEM compliant.<\/p>\n Using this plugin, hopefully you can support complex log forwarding topologies regardless of what technologies the end device uses.<\/p>\n<\/div>\n\n\n\n <\/p>\n","protected":false},"excerpt":{"rendered":" Using a new Logstash output plugin to dynamically route UDP Traffic from a Spoofed IP and MAC Address.<\/p>\n","protected":false},"author":1,"featured_media":220,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[7],"tags":[14,16],"class_list":["post-198","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-elasticsearch","tag-elk","tag-logstash"],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/tonysbit.blog\/wp-content\/uploads\/2019\/10\/advanced-log-forwarding-topology-2.png?fit=847%2C456&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tonysbit.blog\/index.php?rest_route=\/wp\/v2\/posts\/198","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tonysbit.blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tonysbit.blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tonysbit.blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tonysbit.blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=198"}],"version-history":[{"count":0,"href":"https:\/\/tonysbit.blog\/index.php?rest_route=\/wp\/v2\/posts\/198\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tonysbit.blog\/index.php?rest_route=\/wp\/v2\/media\/220"}],"wp:attachment":[{"href":"https:\/\/tonysbit.blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tonysbit.blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tonysbit.blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}The ELK Log Forwarding Topology<\/h2>\n<\/div>\n\n\n\n
Logstash Output Plugin – Spoof<\/h2>\n
\n
Getting Started<\/h2>\n
Pre-Requisites<\/h3>\n
\n
JNetPCAP<\/h4>\n
\n
wget -O jnetpcap-1.4.r1425 https:\/\/downloads.sourceforge.net\/project\/jnetpcap\/jnetpcap\/Latest\/jnetpcap-1.4.r1425-1.linux64.x86_64.tgz<\/code><\/p>\n
\n
tar -xvf jnetpcap-1.4.r1425<\/code><\/p>\n
\n
cp jnetpcap-1.4.r1425\/libjnetpcap.so \/lib\/<\/code><\/p>\n
\n
sudo apt-get install libpcap-dev<\/code><\/p>\n
Installing the plugin<\/h4>\n
\n
cd \/usr\/share\/logstash<\/code><\/p>\n
\n
.\/bin\/logstash-plugin install --no-verify <path-to-gem>\/logstash-output-spoof-0.1.0.gem<\/code><\/p>\n
Testing the plugin<\/h4>\n
\n
vi \/usr\/share\/logstash\/test.conf<\/code><\/p>\n
\n
input {\n generator { message => "Hello world!" count => 1 }\n}\nfilter {\n mutate {\n add_field => {\n "extra_field" => "this is the test field"\n "src_host" => "3.3.3.3"\n }\n update => {"message" => "this should be the new message"}\n }\n}\noutput {\n spoof {\n dest_host => "<REPLACE WITH YOUR DESTINATION IP>"\n dest_port => "<REPLACE WITH YOUR DESTINATION PORT>"\n src_host => "%{src_host}"\n src_port => "2222"\n dest_mac => "<REPLACE WITH YOUR DESTINATION MAC ADDRESS>"\n src_mac => "<REPLACE WITH YOUR MAC ADDRESS>"\n message => "%{message}"\n interface => "ens32"\n }\n}\n<\/code><\/pre>\n
\n
sudo tcpdump -A -i any src 3.3.3.3 -v<\/code><\/p>\n
\n
.\/bin\/logstash -f test.conf<\/code><\/p>\n
Conclusion<\/h2>\n