Old & busted: C-code New-hotness: Lua Hadriel Kaplan, Oracle.

Slides:



Advertisements
Similar presentations
Time Sheet Training Press the F5 Key to view the Presentation. It may be helpful to have a printed copy of this slide presentation for the practice sessions.
Advertisements

IQuote User Guide (1.2) Use your portal username and password
Copyright © 2003 Pearson Education, Inc. Slide 7-1 The Web Wizards Guide to PHP by David Lash.
Programming with Android: SDK install and initial setup Luca Bedogni Marco Di Felice Dipartimento di Scienze dellInformazione Università di Bologna.
Chapter 16 Graphical User Interfaces
1 Classes and Objects in Java Basics of Classes in Java.
Behzad Samin 0 An End-to-End Overview of a RESTful Web Service.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 12 Introduction to ASP.NET.
Chapter 11 Introduction to Programming in C
1 Advanced with GMail A CYC Electives Module
Wikispaces 101 Training Standards & Interoperability (S&I) Framework May 30, :00 - 5:00pm EDT 1.
AJDT and AspectJ Release Review | © 2007 by SpringSource, made available under the EPL v1.0 1 Release Review: AJDT and AspectJ
EMIS The fun never ends…. 2 Previously… EMIS data -- snapshot submitted once in January, December (special education, CTAE students only), February and.
DIVIDING INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
SUBTRACTING INTEGERS 1. CHANGE THE SUBTRACTION SIGN TO ADDITION
1 G54PRG Programming Lecture 1 Amadeo Ascó Adam Moore G54PRG Programming Lecture 1 Amadeo Ascó 3 Java Programming Language.
1 Processes and Threads Creation and Termination States Usage Implementations.
1 Data Link Protocols By Erik Reeber. 2 Goals Use SPIN to model-check successively more complex protocols Using the protocols in Tannenbaums 3 rd Edition.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Exercise Session 5.
ABC Technology Project
South Dakota Library Network ALEPH v20 Tables © South Dakota Library Network, 2012 ©Ex Libris (USA), 2009 Modified for SDLN Version Last Update:
Page Replacement Algorithms
1 What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting language A scripting language is a lightweight.
CAR Training Module PRODUCT REGISTRATION and MANAGEMENT Module 2 - Register a New Document - Without Alternate Formats (Run as a PowerPoint show)
HORIZONT TWS/WebAdmin TWS/WebAdmin for Distributed
1 Welcome to SAPS Webmail. 2 Things we will learn about: 1. Login to mail.
CREATING A PAYMENT REQUEST FOR A NEW VENDOR
4 Oracle Data Integrator First Project – Simple Transformations: One source, one target 3-1.
1 CS 446 – Tutorial 6 Frid. Nov. 6 th, 2009 Implementation Tutorial.
1 Advanced C Programming from Expert C Programming: Deep C Secrets by Peter van der Linden CIS*2450 Advanced Programming Concepts.
1 The C Language An International Standard CIS2450 Professional Aspect of Software Engineering.
CMPT 275 Software Engineering
1 NS-2 Tutorial COMP R2 University of Manitoba March 4, 2009.
© 2008 Security Compass inc. 1 Firefox Plug-ins for Application Penetration Testing Exploit-Me.
Xbox Indie Scene 2014 Mike Froggatt Xbox Advanced Technology Group AMD AND MICROSOFT GAME DEVELOPER DAY - June , STOCKHOLM.
How to create a wiki using pbwiki. Step 1: Choose a wiki website I have chosen.
Executional Architecture
Purpose : To convert this string to a new character array. Return Type : char[ ] Parameters : none Declaration : public char[ ] toCharArray() Returns.
DB Relay An Introduction. INSPIRATION Database access is WAY TOO HARD The crux.
Presented by Douglas Greer Creating and Maintaining Business Objects Universes.
Semantic multimedia annotation tool Tutorial authors : Batatia, Piombo
Addition 1’s to 20.
25 seconds left…...
Week 1.
Stack & Queues COP 3502.
A lesson approach © 2011 The McGraw-Hill Companies, Inc. All rights reserved. a lesson approach Microsoft® PowerPoint 2010 © 2011 The McGraw-Hill Companies,
Introduction to Recursion and Recursive Algorithms
Manipulating Bit Fields in C Noah Mendelsohn Tufts University Web: COMP 40: Machine.
Introduction to Programming G51PRG University of Nottingham Revision 1
Order of Operations And Real Number Operations
Chapter 8 Improving the User Interface
Chapter 16 Graphical User Interfaces John Keyser’s Modifications of Slides by Bjarne Stroustrup
What’s new in WebSpace Changes and improvements with Xythos 7.2 Effective June 24,
Abstraction, Modularity, Interfaces and Pointers Original slides by Noah Mendelsohn, including content from Mark Sheldon, Noah Daniels, Norman Ramsey COMP.
CIS 4004: Web Based Information Technology Spring 2013
12-Apr-15 Analysis of Algorithms. 2 Time and space To analyze an algorithm means: developing a formula for predicting how fast an algorithm is, based.
Kit Chan ATS Lua Plugin Kit Chan Hi, My name is kit.
LV2IDL, a software package for automatic data transfer between LabVIEW and IDL Gelu M. Nita New Jersey Institute of Technology.
Changing Wireshark with Lua. Changing Wireshark with Lua: Writing a Lua Plug-in to Create a Custom Decoder Hadriel Kaplan 128 Technology, Inc.
Game Scripting By: Nicholas Haines. Aurora Neverwinter Toolset.
Introduction to FORTRAN
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
Game Scripting by: Nicholas Haines. What is Scripting? Interpreted Language Interpreted Language –As the game runs.
JavaScript Scripting language What is Scripting ? A scripting language, script language, or extension language is a programming language.
Announcements Assignment 2 Out Today Quiz today - so I need to shut up at 4:25 1.
Python’s Standard Library Part II Dennis Tran. Output Formatting The repr module provides a version of repr() customized for abbreviated displays of large.
Topics Introduction Hardware and Software How Computers Store Data
Topics Introduction Hardware and Software How Computers Store Data
The Lua Chunk Vault, an enhancement to epics base
Presentation transcript:

Old & busted: C-code New-hotness: Lua Hadriel Kaplan, Oracle

Resources

Sharkfest 2014 Agenda Intro to Lua What can you do with it? Lua for Wireshark Tutorial script New stuff in 1.12

What’s Lua? Small but powerful scripting language Interpreted, dynamically typed, etc. Extremely fast Size: ~200KB Created by Pontifical Catholic University of Rio de Janeiro, Brazil As a language, it’s very simple Few keywords, data types, semantics Runs on anything, in pure ANSI C Popular for plugins in embedded systems, games, and of course Wireshark 4

Why Lua? I don’t know why Wireshark chose it originally, but… There aren’t actually that many reasonable choices for a plugin-style language Python, JavaScript, and Lua are common ones to choose from There was a Python API for Wireshark, but it wasn't maintained so it’s been removed If you want one, feel free to submit code 5

Why Lua vs. C? Easier/faster to learn Lua than C Don’t have to deal with compiling Wireshark from source code, nor deal with git Make changes and distribute to users as a plugin, vs. waiting for next Wireshark release Much more stable API across Wireshark versions vs. C-based dynamic plugins Backwards-compatibility is not guaranteed, but is very rarely broken 6

Why not Lua vs. C? #1 reason: support for bug fixes Native C-based dissectors in the git repo can be fixed by other developers There is no central repo for Lua scripts, nor a sufficiently large number of Lua developers to manage them Other reasons: C-code is faster (marginally) C-code can still do things Lua cannot C-code distribution handled by wireshark.orgwireshark.org 7

What can you do with Lua? Protocol dissectors Any protocol type at any layer Custom stats/counters Advanced expert analysis Save packets to pcap files, using custom criteria Add new GUI menu items for actions Read/write from/to custom packet file formats Load log files and view entries as “frames” Fileshark 8

Lua for Wireshark 9

The life of a Lua script in Wireshark When you start wireshark/tshark, the following happens (simplified view): 1.C-code initializes most of the native code items, including native protocol dissectors, taps, etc. 2.Reads and executes the Lua scripts 3.Registers tap listeners 4.Reads preference file 5.Parses command-line arguments 6.etc… 10

Loading Lua plugins Wireshark comes with a Lua script called “init.lua”, in This init.lua script is always loaded There’s a Lua variable to disable Lua scripts inside this init.lua script Then it loads /init.lua Then it loads all “*.lua” Lua scripts in Then it loads any scripts from the command line ( - X lua_script:foo.lua ) 11

The init.lua script The init.lua file in is important Don’t muck with this file It sets a lot of variables that are needed by your Lua scripts Only change the “disable_lua” and “run_user_scripts_when_superuser” variables, if any The init.lua in is different, and should NOT contain the same variables/info as the one in I.e., don’t just copy the file over Because the same variables will overwrite the ones in 12

Inside a script Note that a Lua script is executed during startup of Wireshark, but most of the things it does happen much later That’s because a script usually does most of its work inside functions, and those functions only get invoked later by Wireshark Wireshark knows to call those functions later, because they’re registered as callbacks Usually by being a function of an object that is registered by the script Either registered explicitly, or added to a table 13

New stuff in

Well… not all the new stuff A lot of additions/enhancements in too many to enumerate all of them here The following slides will cover the highlights All changes are listed here: Also, the API docs now indicate what Wireshark version a new function appears in For example, “ Since: ” 15

Heuristic dissector support Previously, only specific dissectors or general post- dissectors could be implemented Now you can create a heuristic dissector 16

64-bit integer support Lua numbers are double-precision floating points (a C-code double), which means they are integer precise up to ~53bits This is a problem if you need to count higher than that, or if you need to convert a 64-bit integer protocol field to a Lua number So Wireshark now has full support for both signed Int64 and unsigned UInt64 objects They now support math operations, comparisons, conversions, etc. 17

Binary structures: Struct library Wireshark already had a ByteArray object to represent arrays of binary bytes But it’s cumbersome to work with in Lua, and only supported going to/from packet contents Now it also has the popular Struct library Can encode/decode Lua binary strings to/from Lua variables Supports endianess control, padding, etc. Since it is to/from a Lua string, it can be used on things other than packet contents For example, file contents 18

True regex support Lua has its own “pattern” matching language engine, which is similar but different to regular expressions A simplistic implementation designed for a small code size It’s slow and weak, so most people import a real regex library The Glib Regex implementation has now been exposed into Lua, for PCRE-based regex support Based on the popular Lrexlib library, with minimal differences 19

Command-line arguments Previously in Wireshark and tshark you could load Lua scripts through the command-line: tshark -X lua_script:myscript.lua Now you can pass the script command-line arguments as well: tshark -X lua_script:myscript.lua -X lua_script1:foo -X lua_script1:bar tshark -X lua_script:my.lua -X lua_script:other.lua -X lua_script2:bar 20

Custom file format read/write Wireshark already natively supports numerous packet file formats But there are other files that contain packet content that might be useful to view as packets For example, application-layer messages as received/sent by the application, not the lower- level Or log files for activity, debug, etc. (logshark?) 21

Viewing file meta data Since you can now read any file format, and you can create any “protocol” dissector, you can create fileshark in Lua The concept of fileshark is to let you use wireshark to open various file formats, and view the file’s format information as frame decoded data e.g., view an MPEG file’s internal format details, such as file header info, image info, etc. 22

Test suites Not a user feature per se, but 1.11 added many test suites for Wireshark’s Lua API This should (hopefully) reduce the number of initial bugs as well as regressions There weren’t very many to begin with, but with all the additions we’re hoping to keep it low If you have Lua scripts you’d like to be included in automatic testing, let me know 23