Posts

Web Api Create method with multiple parameters

Also, how to overload a method, say GET or PUT? Well, lets start that with simple settings, you can't. Too many resources with partial examples makes you sometimes believe that it should be that simple (and maybe it should?), while its not. It's also not that complicated... Part 1 - understanding default design When you create a new Web Api project (in vs 2017 Web Application -> empty, mark web api) you get basically nothing but the " WebApiConfig.cs " withing the "interesting" line is routeTemplate: "api/{controller}/{id}", And that means that whatever controller you create by default can only have it's 1st parameter, as in the url part, as " id ". You cant create a method sending something like " string name ". Next step will be creating a controller class (with the (v2.1) in the end) and you will always get the suggestion of " ValuesController1 ". You cannot have the end of the controller name o...

How to access ngFor variable from child component or directive

the answer is  ViewContainerRef when you inject it into your constructor it has so much data in it. the ngFor data is in this . vc [ '_view' ][ 'context' ][ '$implicit' ] directive full example @ Directive ({     selector:   'td' }) export   class   AddInvAmountBtnDirective   implements    AfterViewInit  {   el : HTMLElement    constructor ( ref : ElementRef , private   vc :  ViewContainerRef ) {      this . el  =  ref . nativeElement   }   @ HostListener ( 'click' , [ '$event' ])  tdClick ( ev :  Event ){      console . log ( 'vc._view.context.$implicit' ,          this . vc [ '_view' ][ 'context' ][ '$implicit' ]);      ev . stopPropagation ()   } }

C# Asp.Net Mvc Impesonate in inner Ajax

Image
Scenario - an MVC app, while in the C# we are calling a REST api. To make the job easier we are using RestSharp The API is an inner api, using windows authentication my steps: 1. using NtlmAuthenticator 2. using default credentials 3. web config - added all the following 4. IIS -> your site -> Authentication -> changed to the following

The great angular dynamic (components) edit page

Image
This one is a long story... My comps goes like this, I GET from API a list of config rows, each of those has a list of config fields, each of those dynamically renders to an appropriate component, 2 of them are inherited 1 from another. The flow is: 1. CTOR and ngOnInit, subscribce to 2 observables, 2 http requests for data. 2. Both subscribces call a ready fn that triggers the *ngIf 3. Then there is an *ngFor for the rows and another  *ngFor  for the fields 4. Down there I have my #container 's for placement of a dynamic component 5. In some cases, since the dynamic component is inherited, its calling ngOnInit twice (its parent's  ngOnInit ) Lets see how can we overcome each of these problems... For implementation, see in my specially crafted git . Problem 1:  the containers prop (my QueryList ) is undefined @ ViewChildren ( 'container' , { read: ViewContainerRef }) containers : QueryList < ViewContainerRef >; In Part 1 of my ...

sharepoint 2013 workflow copy list item to another site - FULL TUTORIAL

Image
This also works for SP2016, and most likely 2019. There are quite a few tutorials out there, but each missing a step, so this is going to be a full one top to bottom. I will make a rich tutorial with pictures, but lets review the steps, and how its done. Workflows doesn't have a way to copy list items to another site, so you need to make an HTTP Request for that, with the Rest API. Also Workflows can't build really JSON objects, so we will need to create Workflow Dictionaries. 1. Have a source list on site A, and a destination list on site B, and open SharePoint Designer 2013 on site A. 2. Learn and test Rest request for adding an item. 3. Build our Workflow, and lets not forget to make the Request as an "App Step" 4. Enable site feature for app step 5. Give the app permissions on site B 6. Run on Item Created (for the example) 7. Error Handling So lets go! 1. Have a source list on site A, and a destination list on site B, and open SharePoint Desig...

Illegal state: Could not load the summary for directive

The above error in my case was because one of our own node modules was compiled with "node_modules" lib inside, after deleting it all worked again. Note that with "ng build" we didnt get any errors only with "ng build -prod" (no need for double dash "--")

Error publishing (to Azure) dotnetcore app after upgrading from dotnetcore 2.0 to 2.1

Image
Background: We just upgraded from dotnetcore 2.0 to 2.1. Most stations had the build successfully except 1, but that was because he had some dependencies projects of his own, we changed them all to 2.1 and he also had referenced one of them both in Assembly and in Projects, we removes the assembly as suggested in stackoverflow . Then while trying to publish we got this exception in most stations: Assets file '(project)\obj\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v2.0'. Ensure that restore has run and that you have included 'netcoreapp2.0' in the TargetFrameworks for your project . Most answers hiding in github mentioned deleting the bin and obj, and than help a couple of stations. We then also Clean and Rebuild, but that also helped just a couple more. Eventually by mistake I played and changed the Publish Configuration Settings, Save, Publish, and back to old configuration and it worked. I guess that it cleaned it ow...

Microsoft Flow - Form, into excel, create word document from template, send email, addressing Copy/Create File errors

Image
Today a customer showed me a paper (invoice) recipe  he had to write into an excel, and then again into a word "thank you" for printing/emailing. If you're here for the Copy/Create File errors, jump to the end. So what we did is to prepare a Form for inputs, and then a Flow that takes that data, use " Insert Row " for excel. Next was to create the word document. I've tried to create custom properties myself, but didn't manage so I followed Netwoven's tutorial , and the simple steps are: 1 - Create a Sharepoint Document Library and add your custom properties to the library as custom Fields. 2 - Go to  Library Settings > Advanced Settings > click Edit Template 3 - The template will open an empty word document, edit it however you want 4 - Wherever you want one of the dynamic custom properties to fit in put your cursor there and click Insert > Quick Parts > Document Property > your custom Fields name 5 - Save the document as a...

Microsoft Flow - auto post in twitter and pinterest

The task at hand - a form, when filled, creates a post at [all] social networks, this blog is about twitter and pinterest. Part 1 - prepare the image Twitter needs "file content" in its media field, while pinterest needs an image url open to the public. So [1st flow] was in OneDrive folder for those uploaded images, sending back the image ID to be used in the form. Can take a few minutes, sent to mail (better to send with the image). The twitter account will create the public url for the image. Part 2 - the form Most simple form, Title, Content and image id into [2nd flow] a Sharepoint list. If you're sure you're never going to use more than 255 characters you can just use the title (i dont like to extend title fields characters limit). Part 3 - to the social media Next [3rd flow] when the SPItem is created, I use OneDrive "Get file content" for the file content and the "Title - Content" for the text, and post a new tw...

Becoming a (very Jn.) Hacker, how to, and my 1st Black Box Test

~ This is not a technical post, its a story post. ~ A story to whom just like stories, or to whom like to learn some lessons, and especially to anyone that wants to become a hacker. Lately (like 6 last months) i'm starting to really go into hacking, it always interested me, but i could never find the time, plus, there was always another challenge @work like the new Angular. But with time and effort, payment has become bigger, and with it my time. And the 1st thing was how... from some videos and many SQL injections or XSS, DVWA ect. I didnt feel i'm learning anything other then extra web security. Finally i found OverTheWire website, and finally i learn some "real" things, linux, php, memory, crypto, ssh, ect., all basics that I, as a web-programmer, had no clue. Only the web-based challenges were "natural" for me. I can say that there I learned lesson no.1 - LEARNING. In the world of hacking, you must be a weary-less learner, new things every ti...

Damn Vulnerable Web Application (DVWA) - File Inclusion and WebShells

today we are going to have some fun understanding the full potential of File Inclusion attacks. my goals for today 1. a few words, Disclaimer, Lab, and links. 2. Web Shells intro with DVWA 3. How to complete the File Inclusion challenge in the new DVWA 4. Metasploit 1. a few words, Disclaimer, Lab, and links. DISCLAIMER - if you do what i teach you today you WILL go to jail. so dont do this outside of your lab. Setting up the lab - For a hacking lab download either VirtualBox or VMWare, or, if you own win10pro, you have Hyper-V. With those you can create virtual machines, and you will need 2 today, one with DVWA, and another as the attacker, which for ease better be kali, download machines from osboxes . For DVWA you can either download Metasploitable 2 or set up dvwa in some machine. In my case i just turned them both on an internal network, so they can see each other but no internet (might need to set up DHCP if you dont have any ip). For basic help about solvi...

Damn Vulnerable Web Application (DVWA) - installation 2018

for anyone trying today to install DVWA, thing changed a little, took me a while to get it working, so here it is: IMPORTANT -  su if you are not root user (i.e. not kali) 1. download the latest version  to get it working with MariaDB and PHP v7.x wget https://github.com/ethicalhack3r/DVWA/archive/master.zip && unzip master.zip unzip under /var/www/html, rename folder to dvwa 2. config file cd /var/www/html/dvwa/config cp config.inc.php.dist config.inc.php gedit config.inc.php create captcha keys https://www.google.com/recaptcha/intro/index.html and set in $_DVWA[ 'recaptcha_public/private_key' ] start at low difficulty $_DVWA[ 'default_security_level' ] = 'low'; you need to clean cookies if the dvwa was running 3. set user in MariaDB sudo service mysql start mysql -u root -p db commands... mysql > create database dvwa; mysql > CREATE USER dvwa@localhost IDENTIFIED BY 'p@ssw0rd'; mysql > grant al...

Real Hacking Challenge - victim behind ssh

Image
the challenge is like this, i have the attacker machine (A), which connect with ssh client to another machine (B), which run ssh server (daaa...), these 2 are connected to the internet, but (B) is also connected to an internal network, and there there is a WIN10 machine (C), NOT connected to the internet but to (B) as said. we will use the help of ssh, ShellTer  to try also do it with windows defender on. to succeed we will try to do this from bottom to top. *DISCLAIMER - all this is illegal, and you may only do it at your lab, if you hack really you will go to jail. *BIG NOTE : sometimes stuff just dont work, restarting (not power off) the machines, and the services refreshes stuff and then they work. PLAN 1. prepare lab 2. test exploit on xp 3. test 3 machines ssh with 3 linux 4. exploit xp via ssh 5. exploit win10 6. test ssh with win 10 7. exploit win10 via ssh 1. preparing lab using VBox (doesnt matter) i will create 4 machines, an arbitrary linux fo...