Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Wednesday, 1 March 2017

HB Blog 130: How To Scan Network With Nmap GUI.

Nmap is popular network scanner software that can actively probe a particular host or a network to infer in-depth information about them. Nmap can conduct host discovery, service detection, OS version identification, port scanning, network stack fingerprinting, etc. It will help you to discover hosts, protocols, open ports, services and its configuration and vulnerabilities on networks. While Nmap itself is a command-line utility, you can run it along with its GUI front-end called Zenmap. Network Mapper is an Android frontend for well known Nmap scanner. Frontend will help you to download and install Nmap as well as use it. Frontend supports all known Android architectures: arm, mips and x86. Nmap binaries are transferred using HTTPS by default.

In this tutorial, I will describe how to scan particular hosts or networks by using Nmap GUI.
The following screenshot shows the main window of Zenmap.
Scan Particular Host(s):-
Using Zenmap interface, you can probe a particular host. Fill in the IP address or host name of a destination host in "Target" field, and choose a desired scan profile from "Profile" drop down menu. Then, click on "Scan" button. For multiple hosts, you can specify them in a comma-separated list.
To check the detailed system information of a particular host after scanning, highlight a host in the left panel, and click on "Host Details" tab on the right panel.
To view available services and open ports of a host, click on "Ports / Hosts" tab.
Scan an Entire Network:-
Zenmap can also probe an entire local network by specifying an address prefix (e.g., 192.168.1.0/24) in the "Target" field.
Once network scanning is completed, you can view the topology of discovered hosts by clicking on "Topology" tab.
To view a list of available services, click on "Services" button on the left panel. You can see a list of all discovered services and their associated hosts, as shown below.

Monday, 1 August 2016

HB Blog 116: Security With HTTPS And SSL.

The Secure Sockets Layer (SSL) technically known as Transport Layer Security (TLS) is a common building block for encrypted communications between clients and servers. It's possible that an application might use SSL incorrectly such that malicious entities may be able to intercept an app's data over the network. To help you ensure that this does not happen to your app, this article highlights the common pitfalls when using secure network protocols and addresses some larger concerns about using Public-Key Infrastructure (PKI).
In a typical SSL usage scenario, a server is configured with a certificate containing a public key as well as a matching private key. As part of the handshake between an SSL client and server, the server proves it has the private key by signing its certificate with public-key cryptography.However, anyone can generate their own certificate and private key, so a simple handshake doesn't prove anything about the server other than that the server knows the private key that matches the public key of the certificate. One way to solve this problem is to have the client have a set of one or more certificates it trusts. If the certificate is not in the set, the server is not to be trusted.
There are several downsides to this simple approach. Servers should be able to upgrade to stronger keys over time ("key rotation"), which replaces the public key in the certificate with a new one. Unfortunately, now the client app has to be updated due to what is essentially a server configuration change. This is especially problematic if the server is not under the app developer's control, for example if it is a third party web service. This approach also has issues if the app has to talk to arbitrary servers such as a web browser or email app.
In order to address these downsides, servers are typically configured with certificates from well known issuers called Certificate Authorities (CAs). The host platform generally contains a list of well known CAs that it trusts. Android currently contains over 100 CAs that are updated in each release. Similar to a server, a CA has a certificate and a private key. When issuing a certificate for a server, the CA signs the server certificate using its private key. The client can then verify that the server has a certificate issued by a CA known to the platform.
However, while solving some problems, using CAs introduces another. Because the CA issues certificates for many servers, you still need some way to make sure you are talking to the server you want. To address this, the certificate issued by the CA identifies the server either with a specific name such as gmail.com or a wildcarded set of hosts such as *.google.com.

The following example will make these concepts a little more concrete. In the snippet below from a command line, the openssl tool's s_client command looks at Wikipedia's server certificate information. It specifies port 443 because that is the default for HTTPS. The command sends the output of openssl s_client to openssl x509, which formats information about certificates according to the X.509 standard. Specifically, the command asks for the subject, which contains the server name information, and the issuer, which identifies the CA.
1
2
3
$ openssl s_client -connect wikipedia.org:443 | openssl x509 -noout -subject -issuer
subject= /serialNumber=sOrr2rKpMVP70Z6E9BT5reY008SJEdYv/C=US/O=*.wikipedia.org/OU=GT03314600/OU=See www.rapidssl.com/resources/cps (c)11/OU=Domain Control Validated - RapidSSL(R)/CN=*.wikipedia.org
issuer= /C=US/O=GeoTrust, Inc./CN=RapidSSL CA
You can see that the certificate was issued for servers matching *.wikipedia.org by the RapidSSL CA.

Assuming you have a web server with a certificate issued by a well known CA, you can make a secure request with code as simple this:
1
2
3
4
URL url = new URL("https://wikipedia.org");
URLConnection urlConnection = url.openConnection();
InputStream in = urlConnection.getInputStream();
copyInputStreamToOutputStream(in, System.out);

Suppose instead of receiving the content from getInputStream(), it throws an exception:
This can happen for several reasons, including:
  •     The CA that issued the server certificate was unknown
  •     The server certificate wasn't signed by a CA, but was self signed
  •     The server configuration is missing an intermediate CA
Here is the example in full using an organizational CA from the University of Washington:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Load CAs from an InputStream
// (could be from a resource or ByteArrayInputStream or ...)
CertificateFactory cf = CertificateFactory.getInstance("X.509");
// From https://www.washington.edu/itconnect/security/ca/load-der.crt
InputStream caInput = new BufferedInputStream(new FileInputStream("load-der.crt"));
Certificate ca;
try {
    ca = cf.generateCertificate(caInput);
    System.out.println("ca=" + ((X509Certificate) ca).getSubjectDN());
} finally {
    caInput.close();
}

// Create a KeyStore containing our trusted CAs
String keyStoreType = KeyStore.getDefaultType();
KeyStore keyStore = KeyStore.getInstance(keyStoreType);
keyStore.load(null, null);
keyStore.setCertificateEntry("ca", ca);

// Create a TrustManager that trusts the CAs in our KeyStore
String tmfAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
TrustManagerFactory tmf = TrustManagerFactory.getInstance(tmfAlgorithm);
tmf.init(keyStore);

// Create an SSLContext that uses our TrustManager
SSLContext context = SSLContext.getInstance("TLS");
context.init(null, tmf.getTrustManagers(), null);

// Tell the URLConnection to use a SocketFactory from our SSLContext
URL url = new URL("https://certs.cac.washington.edu/CAtest/");
HttpsURLConnection urlConnection =
    (HttpsURLConnection)url.openConnection();
urlConnection.setSSLSocketFactory(context.getSocketFactory());
InputStream in = urlConnection.getInputStream();
copyInputStreamToOutputStream(in, System.out);

Sunday, 18 October 2015

HB Blog 98: Go Programming Language - Google's Open Source Project.

Go, also commonly referred to as golang, is a programming language, an open source project developed at Google. It is expressive, concise, clean, and efficient. Its concurrency mechanisms make it easy to write programs that get the most out of multicore and networked machines, while its novel type system enables flexible and modular program construction. Go compiles quickly to machine code yet has the convenience of garbage collection and the power of run-time reflection. It's a fast, statically typed, compiled language that feels like a dynamically typed, interpreted language.
Go was born out of frustration with existing languages and environments for systems programming. Programming had become too difficult and the choice of languages was partly to blame. One had to choose either efficient compilation, efficient execution, or ease of programming; all three were not available in the same mainstream language. Programmers who could were choosing ease over safety and efficiency by moving to dynamically typed languages such as Python and JavaScript rather than C++ or, to a lesser extent, Java.

Go is an attempt to combine the ease of programming of an interpreted, dynamically typed language with the efficiency and safety of a statically typed, compiled language. It also aims to be modern, with support for networked and multicore computing. Finally, it is intended to be fast: it should take at most a few seconds to build a large executable on a single computer. To meet these goals required addressing a number of linguistic issues: an expressive but lightweight type system; concurrency and garbage collection; rigid dependency specification; and so on. These cannot be addressed well by libraries or tools; a new language was called for.

It is a statically-typed language with syntax loosely derived from that of C, adding garbage collection, type safety, some dynamic-typing capabilities, additional built-in types such as variable-length arrays and key-value maps, and a large standard library. Although it borrows ideas from existing languages, it has unusual properties that make effective Go programs different in character from programs written in its relatives. A straightforward translation of a C++ or Java program into Go is unlikely to produce a satisfactory result—Java programs are written in Java, not Go. On the other hand, thinking about the problem from a Go perspective could produce a successful but quite different program. In other words, to write Go well, it's important to understand its properties and idioms. It's also important to know the established conventions for programming in Go, such as naming, formatting, program construction, and so on, so that programs you write will be easy for other Go programmers to understand.
Refer below link to download the Go distribution:-
https://golang.org/dl/

Project structure:-
 Go code must be kept inside a workspace. A workspace is a directory hierarchy with three directories at its root:
    src contains Go source files organized into packages (one package per directory),
    pkg contains package objects, and
    bin contains executable commands.

The go tool builds source packages and installs the resulting binaries to the pkg and bin directories.
The src subdirectory typically contains multiple version control repositories (such as for Git or Mercurial) that track the development of one or more source packages.

To give an idea of how a workspace looks in practice, here's an example:

bin/
    hello                          # command executable
    outyet                         # command executable
pkg/
    linux_amd64/
        github.com/golang/example/
            stringutil.a           # package object
src/
    github.com/golang/example/
        .git/                      # Git repository metadata
    hello/
        hello.go               # command source
    outyet/
        main.go                # command source
        main_test.go           # test source
    stringutil/
        reverse.go             # package source
        reverse_test.go        # test source


This workspace contains one repository (example) comprising two commands (hello and outyet) and one library (stringutil).
A typical workspace would contain many source repositories containing many packages and commands.
Commands and libraries are built from different kinds of source packages.

Check that Go is installed correctly by building a simple program, as follows.
Create a file named hello.go and put the following program in it:
package main
import "fmt"
func main() {
    fmt.Printf("hello, world\n")
}

Then run it with the go tool:
$ go run hello.go
hello, world

If you see the "hello, world" message then your Go installation is working.

An interactive introduction to Go in three sections. The first section covers basic syntax and data structures; the second discusses methods and interfaces; and the third introduces Go's concurrency primitives. Each section concludes with a few exercises so you can practice what you've learned.
Refer below link to download the Go distribution:-
https://tour.golang.org/

Tuesday, 7 October 2014

HB Blog 27: How To Install Kali Linux On Android Device Using Linux Deploy.

From the creators of BackTrack comes Kali Linux, the most advanced and versatile penetration testing distribution ever created.
Linux in a chroot on almost any modern device that runs Android. In fact, the developers of Linux Deploy have made it extremely easy to get any number of Linux distributions installed in a chroot environment using a simple GUI builder. 

Requirements:-
  1.  A smartphone/tablet running Android 2.1 and above, which needs to be rooted since it requires root permission to run certain scripts.
    For rooting android smartphone you can follow my blog Step By Step Guide How To Root Mobile Device.
  2. At least 5 GB free space on internal or external storage.
  3. A fast, wireless internet connection.
  4. Patience to wait for a distribution to bootstrap from the network. 
  5. Following Android Apps:
    BusyBox: It acts like a installer and uninstaller.it needs root permission to run.it has gpu cores and can  run linux kernals on android .
    Superuser: This app just grants a superuser power to your phone just like “su” does for linux.
    Terminal Emulator: It is app that runs a terminal console in android .
    AndroidVNC: It is a tool for viewing VNC in Android.
    Linux Deploy:It creates a disk image on the flash card, mount it and install there OS distribution.
Installation:-
1)Start up Linux deploy app and press the little arrow in the bottom right corner of the screen to open the preferences menu.
2)Configuring the settings as per your requirements.You can choose your architecture, verify that the Kali mirror is correct, set your installation type and location on your Android device, etc.
 3)Then, select "install" option and start installing Linux to your device.It will start a Kali Linux bootstrap directly from our repositories. Depending on your Internet connection speed, this process could take a while. You’ll be downloading a base install of Kali Linux (with no tools) at minimum.
4)After installed go back to preferences and select reconfigure. This will take a couple minutes but will configure Kali with your device.
5)Then just hit "start" option and Linux Deploy automatically mounts and loads up your Kali Linux chroot image. This also includes the starting of services such as SSH and VNC for easier remote access.
6)At this stage, Linux Deploy has started a VNC and SSH server inside your chrooted Kali image. You can connect to the Kali session remotely using the IP address assigned to your Android device.To bring up the graphical interface to see it.Select android vnc viewer and put in these settings. Select new for connection, type anything you want for the nickname, type changeme as the password, and 5900 as port. Now u could use any color settings but the best would be 24-bit. After you fill this out select connect.
 
7)Press Connect and thats all kali is running, when your finished just go back to Linux deploy app and select stop. 

Monday, 6 October 2014

HB Blog 26: How To Install Backtrack On Android Device.

BackTrack was a Linux distribution that aimed at digital forensics and penetration testing use.BackTrack provided users with easy access to a comprehensive and large collection of security-related tools ranging from port scanners to Security Audit.

But, this post is not about backtrack on pc, this is about backtrack on android device.
How To Install Backtrack On Android Device???

Requirements:-
1.Backtrack 5 Arm architecture.
2.A smartphone/tablet which needs to be rooted since it requires root permission to run certain scripts.
For rooting android smartphone you can follow my blog Step By Step Guide How To Root Mobile Device.
3.Following Android Apps:
BusyBox: It acts like a installer and uninstaller.it needs root permission to run.it has gpu cores and can  run linux kernals on android .
Superuser: This app just grants a superuser power to your phone just like “su” does for linux.
Terminal Emulator: It is app that runs a terminal console in android .
AndroidVNC: It is a tool for viewing VNC in Android.

Installation:-
1.Extract the backtrack folder "BT5-GNOME-ARM" to folder named "BT5" on the root of SD card. That’s the top level of the SD card.
2.Open up the Terminal Emulator.
3.Type the command 
cd sdcard/BT5.
4.Run this command and you will see root@localhost.
su   
sh bootbt
5. Now run Backtrack GUI with VNC viewer.
startvnc
6. Open android vnc
Nickname : BT5
Password : toortoor
Address : 127.0.0.1
Port : 5901
7. Connect it and you will see Backtrack 5 interface.