Why Python for Artificial Intelligence (AI)?

Among available programming languages to choose between OOPs approach and scripting, less lines of code, platform independent and flexible language, and easy to learn.Python is developer’s choice when compared with other technologies and OOPs languages because of inbuilt libraries availability, for example, Numpy for scientific computation, Scipy for advanced figuring out/calculating and Pybrain for machine learning, making Python one of the best languages for AI.

For AI, Python leads with more than 50% votes among developers, over popular language like C++. That is because Python is easy to learn and put into use and availability of many libraries used for data analysis.

Python vs C++ for AI:

Python is winner over C++ especially among new developers because C++ being a lower-level language needs/demands more experience and skill to master.

Performance of C++ is better than Python. This is because C++ has the advantage of being a statically typed language and that’s the reason for there are no type related errors during runtime. C++ also creates more compact and faster runtime code. However, Python is a simple (the set of rules for forming language) language which  is faster for development when compared to C++ because it is more natural to (intelligent/obvious) ETL (Extract, Transform, Load) process, and allows developers to test machine learning sets of computer instructions without having to put into use them quickly.

Python vs Java for AI:

The two languages are also written differently. A structure in Java is enclosed in braces. Python uses dent to (do/complete) the same tasks.

Java is also performance wise slower, and for developing high-end computer programs in AI, Python is more preferred by developers.

Java is a compiled language whereas Python is an interpreted language.

Conclusion:

AI needs a lot of research, and because of this we can’t rely on 500 KB commonly used Java code to test a new educated guess which will never finish the project. In Python, almost every idea can be quickly validated through less code. Therefore, it is a pretty useful language for the benefit of AI.

Author: Nandini N – Software Engineer– Test automation framework developer and technology enthusiast at GRhombus.

What is SQL Injection?

SQL Injection is most favorite and most attacked vulnerabilities that Hackers, performs nowadays. From last three times Injection i.e. SQL Injection becomes first web attack published by OWASP.

SQL Injection can be defined as “It is an Injection attack in which attacker tries interface sql queries or sql statement by sending malicious payload to the website.”SQL Injection mainly Categories into three major types:-

In-Band SQL Injection

In-band is common methodology and easy-to-exploit of SQL Injection. In these injection attack, attacker uses same communication channel to both launch the attack and gather results.

In-Band SQL Injection is of two types:-

Error-based Injection:-

Error-based SQLi technique that relies on error messages thrown by the database server to obtain information about the structure of the database. For some Web application, error-based SQL injection alone is enough for a hacker to enumerate an entire database and get the relevant information.

Union-based Injection:-

Union-based SQL injection technique that leverages the UNION SQL operator to combine the results of two or more SELECT statements into a single result which is then returned as part of the HTTP response and tries to get the database information for an attacker.

Inferential Injection:-

Inferential SQL Injection, may take longer time for an attacker to exploit, however, it is some time difficult to exploit the sql injection. In an Inferential SQLi attack, no data is actually transferred via the web application and the attacker would not be able to see the result of an attack as seen in in-band injection. This attacker has to reconstruct the database queries by sending different payload, observing the web application’s response and behavior of database. It is also called as Blind SQL Injection (Blind SQLi).
Inferential band SQL Injection is of two types:-

Boolean-based SQL Injection

Boolean-based SQL Injection is a technique that relies on sending an SQL query to the database which forces the application to return a different result depending on whether the query returns a TRUE or FALSE result.

Time-based SQL Injection

Time-based SQL Injection is a technique that relies on sending an SQL query to the database which forces the database to wait or lock for a specified amount of time (in seconds) before responding. The response time will indicate to the attacker whether the result of the query is TRUE or FALSE.
Basic Syntax for Time based SQL Injection is waitfordelay(), die().

Out-of-band SQL Injection

Out-of-band SQL Injection is most difficult type of SQL Injection that attacker performs, mainly because it depends on features being enabled on the database server being used by the web application. Out-of-band SQL Injection occurs when an attacker is unable to use the same channel to launch the attack and gather results.

Out-of-band SQLi techniques would rely on the database server’s ability to make DNS or HTTP requests to deliver data to an attacker. Such is the case with Microsoft SQL Server’s xp_dirtree command, which can be used to make DNS requests to a server an attacker controls; as well as Oracle Database’s UTL_HTTP package, which can be used to send HTTP requests from SQL and PL/SQL to a server an attacker controls. Happy Hacking !!!!!!!!!

Author: Sujay Chaurasia, Director, Cybersecurity, Development and DevOps, GRhombus Technologies

What is Tcpdump?

Tcpdump is one of the open source tools like Wireshark for network traffic monitoring. Just like in Wireshark, we can dump network traffic using Tcpdump. This tool is easily available in debian like kali Linux. TCPdump is command-line packets sniffer or you can also say as package analyzer tool which is used to capture or filter TCP/IP packets that received or transferred over a network on a specific interfaces.
TCPdump also gives you an option to save captured packets in a file for future analysis. It saves the file in a pcap format, that can be viewed by TCPdump command or an open source GUI based tool like Wireshark that reads TCPdump pcap format files.

How to install tcpdump in Ubuntu/Debian?
You can install tcpdump in Kali linux by using following commands.

$ sudo apt install tcpdump
The general syntax for the tcpdump command is as follows:
$ tcpdump [options] [expression]

  1. The command options allow you to control the behavior of the command.
  2. The filter expression defines which packets will be captured.

To dump the traffic we can you different commands

To capture packets from a particular Ethernet interface

When you execute tcpdump command without any option, it will capture all the packets flowing through all the interfaces. -i option with tcpdump command, allows you to filter on a particular Ethernet interface.
$ tcpdump -i [interface name]
$ tcpdump -i eth1
Above tcpdump captured all the packets flows in the interface eth1 and displays in the standard output. Where ‘-i’ = interface
Note: Editcap utility is used to select or remove specific packets from dump file and translate them into a given format.

To capture only N number of packets

When you execute tcpdump command it gives packets until you cancel the tcpdump command. Using -c option you can specify the number of packets to capture.
$ tcpdump -c 2 -i eth0
Above tcpdump command captured only 2 packets from interface eth0. Where ‘-c’ specify the number of packets to be captured.
Note: Mergecap and TShark: Mergecap is a packet dump combining tool, which will combine multiple dumps into a single dump file. Tshark is a powerful tool to capture network packets, which can be used to analyze the network traffic. It comes with Wireshark network analyzer distribution.

To display captured packets in ASCII

When you want to the packets in ASCII, then you can execute the command.
$ tcpdump -A -i eth0

To display captured packets in HEX and ASCII

When you want to the packets in hex values. tcpdump provides you a way to print packets in both ASCII and HEX format.
$tcpdump -XX -i eth0

To Reading and write the capture packets into a file

tcpdump allows you to save the packets to a file, and later you can use the packet file for further analysis.
$ tcpdump -w <File Name>.pcap -i eth0
-w option writes the packets into a given file. The file extension should be .pcap, which can be read by any network protocol analyzer.
$ tcpdump -r <file_name>.pcap
By using ‘-r’ option that stands for “read”.

To find all network interfaces

When you want to fetch the list of all available network interfaces, we can use the command:
$ tcpdump -D
Use ‘-D‘ option to display all the available interfaces for tcpdump command.

To capture all network packets

To capture all the inbound and outbound network packets we can use ‘any’ option to capture data packets that go through all network interfaces. This can be done by using the interface option ‘-i’.
$ tcpdump -v -i any

To capture packets of a protocol-specific

When you want to capture packets belonging to a particular network protocol, we can append the name of the protocol at the end. You can specify one of these protocols: wlan, ip, ip6, Arp, tcp and udp etc.
$ tcpdump  -i any tcp
The following example captures only arp packets flowing through the eth0 interface.
$ tcpdump -i eth0 arp
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode

To capture host-specific packets

To capture the host specific packets, for that we can use ‘host’ keyword along with ‘tcpdump’, we can filter all the packets that are exchanged with a particular host.
$ tcpdump -nn -c 5 -i any host X.X.X.X
‘-nn’, specify to translates the hostnames to their numeric Internet addresses.
Note: The packets appear only if there is an actual network connection with the specific IP address.

To capture the packet from particular Source or Destination.

To capture the packet from particular Source or Destination We can use option ‘src’ (source) followed by an address.
$ tcpdump -nn -c 5 -i any src X.X.X.X
For destination-specific query, ‘dst’ is used.
$ tcpdump -nn -c 5 -i any dst  X.X.X.X

To receive packets flows on a particular port using tcpdump port

We can capture all the packets received by a particular port on a machine, to capture the packet we can used tcpdump command.
$ tcpdump -i eth0 port 21

To Capture packets for particular destination IP and Port

When we have source and destination IP and port numbers. Using tcpdump we can apply filters on source or destination IP and port number. To captures packets flows though network interface (eth0), with a particular destination ip (X.X.X.X) and specific port number 21.
$ tcpdump -w xpackets.pcap -i eth0 dst X.X.X.X and port 21

To Capture TCP communication packets between two hosts

If there is two different process from two different machines are communicating and they using tcp protocol for communication, then we can capture those packets using tcpdump using command.
$ tcpdump -w comm.pcap -i eth0  src X.X.X.X and port 21 and dst X.X.X.X and port 21

Capturing only IP address packets on a specific Interface

By Using -n option in tcpdump command we can capture only IP address packets on specific interface, example is shown below,
$ tcpdump -n -i eth0

Author: Sujay Chaurasia, Director, Cybersecurity, Development and DevOps, GRhombus Technologies