Exploring RaspberryPi

I borrowed RaspberryPi from my University’s IOT lab

I wanted to do some experiments on Rasp berry pi and create some awesome cool project, just curiousity and exploration. I heard about raspberry pi when i was on my IOT and Hardware hacking exploration, came to know about this amazing mini computer which holds enormous power.

Raspberry Pi application in daily life: Why do we need Raspberry Pi?

Application of Raspberry Pi:

  • Satellites,
  • electric vehicles
  • robots
  • smart houses
  • smart cities

Hands On Raspberry Pi EXploration:

My hardware RPI KIT:

  • Raspberry Pi 3, Model B(Specs: 1GB RAM, Bluetooth 4.1, Wireless LAN,)
  • Raspberry Pi Camera
  • HDMI cable to connect to external Screen
  • Mouse
  • Keyboard
  • SD CARD: To run RaspOS
  • USB type B

Product Description

Raspberry Pi 3  Model B Original with Onboard WiFi and Bluetooth
RAM: 1GB
Processor: Broadcom BCM2387 chipset 1.2GHz Quad-Core ARM Cortex-A53 (64Bit)
802.11 b/g/n Wireless LAN and Bluetooth 4.1 (Bluetooth Classic and LE)
Storage : SD/MMC/SDIO
Power: 5V / 700mA~3A via micro USB

Features :

Processor:
    Broadcom BCM2837 chipset.
    1.2GHz Quad-Core ARM Cortex-A53 (64Bit)
    802.11 b/g/n Wireless LAN and Bluetooth 4.1 (Bluetooth Classic and LE)
GPU:
    Dual-Core VideoCore IV® Multimedia Co-Processor. Provides Open GL ES 2.0, hardware-accelerated OpenVG, and 1080p30 H.264 high-profile decode.
    Capable of 1Gpixel/s, 1.5Gtexel/s or 24GFLOPs with texture filtering and DMA infrastructure
Operating System:
    Boots from Micro SD card, running a version of the Linux operating system or Windows 10 IoT

Connectors and Ports:

Ethernet:
    10/100 BaseT Ethernet socket
Video Output:
    HDMI (rev 1.3 & 1.4)
    Composite RCA (PAL and NTSC)
Audio Output:
    Audio Output 3.5mm jack
    HDMI
    4 x USB 2.0 Connector
GPIO Connector:
    40-pin 2.54 mm (100 mil) expansion header: 2×20 strip
    Providing 27 GPIO pins as well as +3.3 V, +5 V and GND supply lines
Camera Connector:
    15-pin MIPI Camera Serial Interface (CSI-2)
Display Connector:
    Display Serial Interface (DSI) 15 way flat flex cable connector with two data lanes and a clock lane
Memory Card Slot:
    Push/pull Micro SDIO

Power Requirements of Raspberry Pi 3 Model B

You need a 5V, 2.5 Amp micro USB power adapter for powering your Raspberry Pi 3 Model B, can use many of the good Android phone charger to power on your Raspberry Pi 3 Model B. Raspberry Pi 3 Model B consumes about 260 mA of current at 5.0 V (which is about 1.3-1.4 Watt) when no USB devices are connected to it and it’s in idle state If you add more accessories to your Raspberry Pi 3 Model B and Raspberry Pi 3 B+ or if it’s not idle (working), then the power consumption will increase.

Saving Power on Raspberry Pi: If you want to save power, you should of course connect less accessories to your Raspberry Pi and disable the features that you don’t need.

Preparing RaspberryPi Operating System on sdcard

Using Raspberry pi imager-You can find this on official RaspberryPi site, install it and then select the OS of your choice and needs or if you want to select the specific OS head over to aspberrypi.org/software and download the disk image.

The process I followed-

  • We will need a sd card reader, plug in your sdcard (size: atleast 8gb minimum recommended for better performance)
  • Download raspberrypi imager to flash OS on your sdcard(you can use alternatives like Balena etcher too) here we are using raspberry pi imager
  • Plug in your sdcard reader with sdcard inside, and open rpi imager
  • Select the OS you want to install on your rpi based on the rpi model, and version like rpi zero/2/3/4, and based on your sdcard size choose suitable OS. The supported OS are already listed but you can also choose your custor OS Image from your laptop if you have already downloaded it.
  • Select the storage device like for me it is MXT-USB STORAGE DEVICE(basically your sdcard)
  • You can click on the settings icon below to do some advance configurations like set up ssh so that you can access your rpi through your pc’s terminal, set username and password for ssh. Enter the network configurations like your SSID, password etc (Btw, you can do all this later too if you are having ethernet cable at the moment if not then you should enter the wireless configurations to enable wireless LAN)
  • Enter write button.

Based on my personal experiences:

  • Having sdcard with larger size will make your work more hassle free and fast
  • Always keep the backup of your files on your sdcard(because while writing the OS on sdcard if things go wrong can lead to sdcard corruption and you might end up losing your important files)
  • Installing OS can take long time, it depends on the OS you are installing, your internet connection and on the storage device you are using. So please be patient and keep trying until you achieve your goal.

Best uses of raspberry pi:

  1. Penteration testing and hacking: To install kali linux on rpi, flash your drive,

  2. Retro pi: You can buy a normal rpi and play all the old video games mario, super nintendo games,

  3. Use as a desktop, buy keyboard, mouse, monitor, familier with linux raspberry pi os is ubuntu/debian based.

Projects

Used as an open vpn server, home router, NAS, mini computer, robot, creating custom smart tv, etc

Latest model: Raspberry pi 4

Supports all major programming languages like C/C++, Python, C#, Java processor- fast, ports selection, you can watch 4K 60fps video.

Architecture of Raspbery pi- ARM based

It doesnt support windows because Windows 64-bit is x86_64 based architure and Raspi support only ARM based architecture.

Limitations

  • Overheating issues found becuase active cooling is not installed.
  • It is not full fledged computer but it is good for learning more about computers, electronics, programming and hacking in general.
  • Multipurpose, has pros and cons, good for educational purposes, after learning and playing with RaspberryPi people gain hardware knowledge, and general understanding of whats inside their computer systems.

Importance of RASPBERRY PI in hacking

Hacking gadgets that you can try creating RaspberryPi

–to-be-continued–

Kotlin: A brief summary

KOTLIN: Android Development

Kotlin is a general purpose, statically typed language, can be used on client and server(response request from client).

Kotlin is used for android devices, it is an example for programming language, was created on 2011, powerful and easy to use, java and kotlin have a special relationship because they are compatible with each other.

File extension for kotlin files is .kt.

fun main() { println(“hello world”)

}

Strings are sequence of characters

For example:

  •     val myString="KOTLIN" 
        println(myString[0])
        println(myString[1])
        println(myString.isEmpty())//false
        println(myString.length)//6
        println(myString.substring(2,4))//TL
    

Options and methods you get depends on the type of the varible(like strings, integers).

println("The string is &myString) //string interpolation // The string is KOTLIN $ replaces the variable with the content of that variable.

Condition: If and else

  •   fun main(){
      val score=80
      if(score>100){
      println("you passed")
      }
      else{
      println("you failed")
      }
      }
    

//Output: you failed

Collections

To hold a bunch of variables at once. For example: lists.

  •   fun main()
      {
      val names=listOf{"riya","shalini","rakshit"}
      println(names[2]) //rakshit
      names.add("rohit")
    
      }
    

By default, collections in kotlin are immutable–> We cannot add/or remove elements from of a list. But you can achieve that by using mutable keyword.

  •    fun main()
      {
      val names=mutablelistOf{"riya","shalini","rakshit"} 
      println(names[2]) //rakshit
      names.add("rohit")
      }
    

All the elements should be of same type if not then it will throw an error. You can explictly mention it like this:

  •    fun main()
      {
      val names=mutablelistOf<String>{"riya","shalini","rakshit"} //all the elements should be of same type
      println(names[2]) //rakshit
      names.add("rohit")
    
      }
    

For loops

To print each element in a list of names:

  •    fun main()
      {
      val names=mutablelistOf<String>{"riya","shalini","rakshit"} //all the elements should be of same type
      for( name in names){
      println(name)
      }
      }
    

On every cycle/iteration of a for loop, the variable name will take the value of a single element from the list in order.

//Output: riya
shalini
rakshit

Use of for loops: To do something for certain number of times.

  •    for(i in 1..5){
      println(i)
      }
    

//Output:

1
2
3
4
5

  •    for(i in 1 until 5){
      println(i)
      }
    

//Ouput:

1
2
3
4

Functions

Chunk of codes that can be used later. Advantages: Easier to read code, saves space, time and manpower. For example:

  •   fun helloFn(){
      println("hello")
      }
    
  •    fun main(){
      helloFn()
      }
    

//Output

hello

We can give some input to the function as a parameter.

For example:

  •    fun helloFn(name:String){
      println("hello, $name")
      }
    
  •    fun main(){
      helloFn(name: "Riya")
      }
    

//Output

hello Riya

We can set the visibility of a function as private so that they cant be accessed by other classes or files.

For example:

  •    private fun helloFn(name:String){
      println("hello, $name")
      }
    
  •    fun main(){
      helloFn(name: "Riya")
      }
    

NULL/nullability

Having null value, if the variable is allowed to have a null value then you have update the type to include a ? question mark.

Cant call any method on someting which is set to null so we have to check if the variable is not null. For example:

  •    fun main(){
      val name:String? =null
      if(name!=null){
      println(name.toUpperCae())
      }
    

//Output

Here we get a empty output

Another example:

  •    fun main(){
      val name:String? =hello
      if(name!=null){
      println(name.toUpperCae())
      }
    

//Output
HELLO

SHORTHAND for checking NULL

You can use a shorthand of the above if condition by writing name?.toUpperCase() : This means we will only call this method on this variable if it is not null.

val firstName: String="riya" // or val firstName=“riya”

This is type inference.

Built in types in kotlin: double for decimals, and boolean only has true or false.

Comments: Add // double slash to convert any code snippet to comments.

Operators

  •    val s1="hello"
      val s2="key"
      val add=s1+s2 //string concatenation
      println(add)
    

-to-be-continued-

Android Development

Creating a new project in android studio

  1. Create a new project

  2. Create a empty project

  3. Enter name of an app

Make sure to select java as programming language. 4. Click on finish

Your app is created.

404 || error || site underconstruction

Daemons

Linux Daemons

Daemons: Services on Linux that works as background processes. Process- Instance of a running program. For example: Lets launch nano, go to bash and command ps -aux. (pic) We have a process running for nano, now lets close the nano. (pic) Now those processes are gone.

Lets run ps -aux on our bash/terminal. (pic) There are lots of processes running and most of them are daemons.

Daemon are the processes we dont start, they are like services, like in windows we have background processes running known as services like ntp(network time protocal). Similarly, on linux we have daemons (we dont start them), they are essential like printing daemon, ssh daemon, networkiing daemon.

How to differentiate a normal process and a Daemon?

A daemon process will have ‘d’ at the end which stands for daemon like sshd(ssh deamon).

For example: ps -aux | ssh (pic)

How to control Daemons?

  • Managing services in linux running in bg
  • By managing the master daemon: systemd(he commands all the other daemons) it starts, stops and restart the daemon, it is also a daemon, source manager, initiliatiion system(init system),
  • Boot the kernel-> systemd->mounitng the fs->starting the services
  • systemd is the first process and from it other services are started using the process of forking
  • Type pstree(process tree): systemd is the orginal process and all the process is branched off it.
  • ps -aux : You will see each process is having its own process id(pid) you will see pid 1 = systemd
  • There are other init systems too like openrc(gentoo), etc, but most of the linux distros have systemd.

service and process management:

Systemctl (control the daemons)

STOP a linux service

Start a linux service

see linux sercie status

restart a linux service

start a service at boot(enable)

how to hunt for daemons(services)

Troubleshoot linux services(daemons)

MASKING AND TARGETS???