Using C++ and libcurl to retrieve files from the Meijer account page - javascript

I would like to use C++ and libcurl to retrieve files from my Meijer account page. I would like to be here
https://www.meijer.com/mperks/ShoppingTools#receipts.
The login form lives here
https://accounts.meijer.com/manage/Account#/form/user
but exists on multiple pages. In addition, any curl request I make to the above link, such as the following
curl -A "Mozilla/5.0" -L -e ";auto" -c cookie.txt https://accounts.meijer.com/manage/Account#/form/user
returns a page with a warning about the browser not supporting javascript.
Is what I want feasible given C++ and curl?

Related

How can I let multiple Java scripts to run concurrently in Frida?

I want to bypass root detection, certificate pinning, and a crc integrity check for an android app using Frida. I can't run more than 1 script at once, is there any solution?
Concatenate all scripts into one file and load is the trivial (and probably good enough) answer.
I have another suggestion that you can do even without a computer, just put text editor on your device and get a bluetooth keyboard.
frida-inject which can be downloaded from frida release page
Push frida-inject & the scripts to the device and execute the following that iterates scripts , inject them to the process and exists.
for f in $(ls /sdcard/scripts/*js) do; ./frida-inject -p $(pidof com.app.name) -s $f --eternalize
frida-inject options
frida -U -f [APP_ID] -l script1.js -l script2.js
you can try this too

Live console input/output for a gameserver using JavaScript or PHP

General information: I have a Minecraft server running in the basement for some friends that is running for a couple months now. We were using TeamViewer to input commands into the console and view possible errors while the server was running. The console of a Minecraft server basically shows you a log of events with timestamps as well as a command input line at the bottom that enables you to execute in-game commands with administrator rights.
The console is started via a batch file:
:startup
#echo off
set v1=6
cls
Java -Xmx%v1%G -jar spigot.jar nogui
goto startup
The spigot.jar file is the file that basically runs the server.
Because we manage multiple servers and the TeamViewer process is quite insecure and slow, i wanted to find other ways to access the console.
Target: I want to create a HTML webinterface that uses JavaScript or PHP to communicate with the server console. It should be able to show the live console log as well as being able to type commands in the browser that are then executed in the commandline on the server.
Problems:
Is there any way to send a JavaScript/PHP input to the console so that I can execute commands from a webinterface?
Can I save the live console output to a .txt file that the JavaScript/PHP script can then display live on the webinterface?
I would definitely recommend moving your setup outside of a Windows environment, as you're going to have a much easier time hosting a PHP server, etc. in a Linux environment.
Admittedly, I'm not familiar with MineCraft, but it looks like the batch file you have is effectively just launching a Java JAR which can be done from any computer with the JRE installed. Java console apps read input on the STDIN of a process and output on STDOUT for any application-generated output. This is incredibly easy to pickup in a Ubuntu environment.
For example, let's say you install the standard LAMP stack on a fresh Ubuntu install. You'll have PHP for running your server-side process, and Apache for hosting any web interface you decide to build. Keeping a focus on frontend vs. backend, I'd probably try to setup an API in PHP using Slim or another lightweight framework. In the API endpoint you use to start your server, it would look something like this:
exex('screen -d -m -S ServerOne');
exec('screen -S ServerOne -p 0 -X stuff "java -Xmx%v1%G -jar spigot.jar nogui > /some_path_to_log^M"');
The first exec() will create a screen session named "ServerOne" inside of which your server process can run. The second exec() will send the command needed to start your server process inside of the screen session. Effectively, this will run your server asynchronously to your PHP script and write the output to the specified path. Knowing where to expect the output, in the API endpoint you use to get your log, you'd have something like:
$logContent = file_get_content('/some_path_to_log');
Finally, in the API endpoint you use to write commands to your server, you would have something that looks like:
exec('screen -S ServerOne -p 0 -X stuff "<your_command_here>^M"');
This will write to the STDIN stream of your server's Java process which should, in turn, be interpreted as if you were actually typing at the keyboard of the console itself.
That's the basics of it, or at least where I'd get started. There are some pretty cool things that you could do with WebSockets to open a live I/O session for your server's console, but it'd be a bit more involved than this post. If you're interested, check out Ratchet for PHP or ws for Node.js.
Consider this ServerFault post for more information on sending input to screen sessions.
I suppose you could show the log on a website like this:
first gameserver script:
:startup
#echo off
set v1=6
cls
Java -Xmx%v1%G -jar spigot.jar nogui > log.txt
fileup log.txt
goto startup
second gameserver script(called fileup.bat){replace myusername, mypassword and servername.com with the credentials if your php server}:
#echo off
echo user MyUserName> ftpcmd.dat
echo MyPassword>> ftpcmd.dat
echo bin>> ftpcmd.dat
echo put %1>> ftpcmd.dat
echo quit>> ftpcmd.dat
ftp -n -s:ftpcmd.dat SERVERNAME.COM
del ftpcmd.dat
php-server side script:
<?php
$filename = "log.txt";
$fp = fopen($filename, "r");
$content = fread($fp, filesize($filename));
$lines = explode("\n", $content);
fclose($fp);
print_r($lines);
?>
by the way: I have not tested any of these scripts and they might not work, I just based this on my knowledge of php and batch. Also, the second batch script needs to be in the same directory as the first batch script and you do not have to run the second batch script
Note:
I am an experienced PHP user but I do not know very much about batch(I use linux) but I suppose this will work and I have used batch very often in the past. Also I recommend using the PHP script on an external hosted php server from 000webhost.com or infinityfree.net because they are free and save you a lot of time + they have all the needed ftp things preconfigured.
Please let me know if this worked

Downloading text file using curl in HTML

I am trying to download text file from server to local directory.
If I execute following curl command it copies myfile.txt from server and saves in same directory as newfile.txt.:
curl -o newfile.txt http://myserverip/myfile.txt
I want to automate this by running the command from javascript while loading the webpage.
For example if I open an html page (which runs a javascript) like http://myserverip/getnewfile.html in the browser the myfile.txt from the server should be copied to newfile.txt in the loacl directory.
Can anyone help me to write javascript to execute the curl command?
Please note that the server in local area network and router is configured to allow connections only from white-listed mac ids of local machines so there is no any authentication required to connect to server.
You can't run local command-line commands from JavaScript, because that would be a massive security vulnerability. The tool you want to use for this is either window.open (to open a tab with the file in order to cause the browser to download it) or the fetch API (to retrieve the file for use in JavaScript).

CORS policy error on file in same folder as HTML [duplicate]

I am getting the following error:
XMLHttpRequest cannot load file:///C:/Users/richa.agiwal/Desktop/get/rm_Library/templates/template_viewSettings.html. Cross origin requests are only supported for HTTP.
I realize that this question has been answered before, but I still have not found a solution to my problem. I tried running chrome.exe --allow-file-access-from-files from the command prompt, and moved the file to the local file system, but I still get the same error.
I appreciate any suggestions!
If you are doing something like writing HTML and Javascript in a code editor on your personal computer, and testing the output in your browser, you will probably get error messages about Cross Origin Requests. Your browser will render HTML and run Javascript, jQuery, angularJs in your browser without needing a server set up. But many web browsers are programed to watch for cross site attacks, and will block requests. You don't want just anyone being able to read your hard drive from your web browser. You can create a fully functioning web page using Notepad++ that will run Javascript, and frameworks like jQuery and angularJs; and test everything just by using the Notepad++ menu item, RUN, LAUNCH IN FIREFOX. That's a nice, easy way to start creating a web page, but when you start creating anything more than layout, css and simple page navigation, you need a local server set up on your machine.
Here are some options that I use.
Test your web page locally on Firefox, then deploy to your host.
or: Run a local server
Test on Firefox, Deploy to Host
Firefox currently allows Cross Origin Requests from files served from your hard drive
Your web hosting site will allow requests to files in folders as configured by the manifest file
Run a Local Server
Run a server on your computer, like Apache or Python
Python isn't a server, but it will run a simple server
Run a Local Server with Python
Get your IP address:
On Windows: Open up the 'Command Prompt'. All Programs, Accessories, Command Prompt
I always run the Command Prompt as Administrator. Right click the Command Prompt menu item and look for Run As Administrator
Type the command: ipconfig and hit Enter.
Look for: IPv4 Address . . . . . . . . 12.123.123.00
There are websites that will also display your IP address
If you don't have Python, download and install it.
Using the 'Command Prompt' you must go to the folder where the files are that you want to serve as a webpage.
If you need to get back to the C:\ Root directory - type cd/
type cd Drive:\Folder\Folder\etc to get to the folder where your .Html file is (or php, etc)
Check the path. type: path at the command prompt. You must see the path to the folder where python is located. For example, if python is in C:\Python27, then you must see that address in the paths that are listed.
If the path to the Python directory is not in the path, you must set the path. type: help path and hit Enter. You will see help for path.
Type something like: path c:\python27 %path%
%path% keeps all your current paths. You don't want to wipe out all your current paths, just add a new path.
Create the new path FROM the folder where you want to serve the files.
Start the Python Server: Type: python -m SimpleHTTPServer port Where 'port' is the number of the port you want, for example python -m SimpleHTTPServer 1337
If you leave the port empty, it defaults to port 8000
If the Python server starts successfully, you will see a msg.
Run You Web Application Locally
Open a browser
In the address line type: http://your IP address:port
http://xxx.xxx.x.x:1337 or http://xx.xxx.xxx.xx:8000 for the default
If the server is working, you will see a list of your files in the browser
Click the file you want to serve, and it should display.
More advanced solutions
Install a code editor, web server, and other services that are integrated.
You can install Apache, PHP, Python, SQL, Debuggers etc. all separately on your machine, and then spend lots of time trying to figure out how to make them all work together, or look for a solution that combines all those things.
I like using XAMPP with NetBeans IDE. You can also install WAMP which provides a User Interface for managing and integrating Apache and other services.
Simple Solution
If you are working with pure html/js/css files.
Install this small server(link) app in chrome. Open the app and point the file location to your project directory.
Goto the url shown in the app.
Edit: Smarter solution using Gulp
Step 1: To install Gulp. Run following command in your terminal.
npm install gulp-cli -g
npm install gulp -D
Step 2: Inside your project directory create a file named gulpfile.js. Copy the following content inside it.
var gulp = require('gulp');
var bs = require('browser-sync').create();
gulp.task('serve', [], () => {
bs.init({
server: {
baseDir: "./",
},
port: 5000,
reloadOnRestart: true,
browser: "google chrome"
});
gulp.watch('./**/*', ['', bs.reload]);
});
Step 3: Install browser sync gulp plugin. Inside the same directory where gulpfile.js is present, run the following command
npm install browser-sync gulp --save-dev
Step 4: Start the server. Inside the same directory where gulpfile.js is present, run the following command
gulp serve
To add to Alan Wells's elaborate answer here is a quick fix
Run a Local Server
you can serve any folder in your computer with Serve
First, navigate using the command line into the folder you'd like to serve.
Then
npx i -g serve
serve
or if you'd like to test Serve without downloading it
npx serve
and that's it! You can view your files at http://localhost:5000
If you are using vscode, you can easily start a liver server. Click liver server at the bottom of the page, once the server is started, vscode will tell the port the project is running. Do ensure your project folder is the workspace
This error is happening because you are just opening html documents directly from the browser. To fix this you will need to serve your code from a webserver and access it on localhost. If you have Apache setup, use it to serve your files. Some IDE's have built in web servers, like JetBrains IDE's, Eclipse...
If you have Node.Js setup then you can use http-server. Just run npm install http-server -g and you will be able to use it in terminal like http-server C:\location\to\app.
Kirill Fuchs
If you use the WebStorm Javascript IDE, you can just open your project from WebStorm in your browser. WebStorm will automatically start a server and you won't get any of these errors anymore, because you are now accessing the files with the allowed/supported protocols (HTTP).
I was facing this error while I deployed my Web API project locally and I was calling API project only with this URL given below:
localhost//myAPIProject
Since the error message says it is not http:// then I changed the URL and put a prefix http as given below and the error was gone.
http://localhost//myAPIProject
Depends on your needs, but there is also a quick way to temporarily check your (dummy) JSON by saving your JSON on http://myjson.com. Copy the api link and paste that into your javascript code. Viola! When you want to deploy the codes, you must not forget to change that url in your codes!

Forbidden : You don't have permission to access /questions.php on this server

I am beginner in PHP and I got the Error for Developed My Project ERROR is Like:
This: Forbidden
You don't have permission to access /quiz.php on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Please give the suggestion for Solve this problem.
From interpreting the error, I believe that the problem doesn't lie in php but rather in the underlying operating system and filesystem. More specifically, file permissions.
If you are running Apache on Linux the webserver will only be able to serve pages that it can read. This has to do with local filesystem permissions.
I'm taking a leap here, but if your server is run by the user www-data then that user needs read permissions to the .php files in order to serve them as web pages. If these files are in a subdirectory, then that subdirectory and the .php files inside must also be accessible by www-data.
First, make sure that quiz.php is readable by the user www-data, as most likely you would have created this file using a different user account (root? yourself?).
The following command sets the owner of the file quiz.php to www-data
chown www-data quiz.php
This command needs to be issued in the directory where quiz.php is located and it needs to be entered with a user account that has sufficient privileges to change a file's attributes. Normally this is the root account, but it could be you if the server's administrator has given you those permissions.
You can read up on the chown command by typing
man chown
on most Linux systems.

Categories