how to run exe() from browser [closed] - php

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
Hello I'm new to both PHP and python but I'm using them both in my graduation project I have an OTP code to generate a random number and send SMS to phone numbers and another code that runs a fingerprint scanner.both are working fine when I use exec() in PHP to run them in cmd but when using browser only the otp code works with the webpage, I've changed the permission of the apache user and gave it root privileges and tried both system() and exec() functions but still nothing shows up when using trying to execute the fingerprint code from browser
I would appreciate any help because I am stuck on this for many hours days now

I've changed the permission of the apache user and gave it root privileges
OMG no.
If your supervisor (whom is being paid to give you advice) thinks this a good idea, then find another supervisor.
You have not provided nearly enough information to form an opinion on the cause. You need to investigate which file permissions are relevant to the problem - that is Unix filesystem privileges on executables, devices and data files, but you also need to look at any mandatory access control systems which might be in play (SELinux, Apparmor, smack). You should also try running the programs from an interactive shell as the Apache uid. Note that it is usually a good idea to severely restricted the programs the webserver can run and whitelist specific actions for the webserver/webserver uid via sudo.

Related

Laravel 5.2 Login Doesn't Work [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I have a Laravel app in my web server. I wanted to develop it in my local server, so I pushed it to my git server first, then clone to my local server.
After that, first I installed composer and run migrations.
When I open the app from browser, I see login screen. If I use wrong password, It returns an error, however if I enter my correct password, it redirects to login page again.
At first, I thought it is happening because of my local configurations. Then, I copied my web server configuration to another folder. If I use old database config, it works, on the other hand if I change database settings and migrate again, face with same problem.
PS: After every new setup, I generate a new key. I'm not sure if I should change anything else.
I changed session driver from file to cookie, but didn't work.
I also removed all storage/sessions folder.
How can I fix that problem?
Edit:
My Codes (Routes, Controller and Config):
http://laravel.io/bin/MkG7z

How to enable php run python script on GPU? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
In my php website, I call a python script using theano and running on GPU.
However, when calling this python script from php, it seems apache doesn't have any permissions on GPU so the program falls back on CPU, which is far less efficient compared to GPU.
How can I grant apache rights to run programs on GPU?
I would split that up, save the requirement as event in some storage (redis for example or even rabbitmq) and listen to that with some daemonized script (cron would be a bad joice since its hard to make it run more often than every minute). The script will update the storage entry with the results and you can access it again in your http stack. You can implement the functionallity via ajax or utilize a usleep command in php to wait for the results. If using a while loop, dont forget to break it after 1 second or something, so the request is not running too long.
Your problem might be the configured user, that executes the php binary - it maybe not permitted to access those binaries on your system. Typically its the www-data user. By adding the www-data user to the necessary group, you might be able to solve it without splitting all up. Have a look at the binary's ownerships and permissions to figure that out.

Making php script executable [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I'm filling out a job application which has asked me to write a function which you submit to them as a .php file. The last line of the specification says:
Make sure your file can be executed from the command line: php meats.php (this helps us to check if the code works before even looking at it)
Does anyone know what that means? I've checked that function works fine on my hosting environment but I'm just not sure there is something else I need to do??
Thank you
Without seeing your code, you'll need to make sure it's not using anything that's dependent on being run rendered in the browser executed on the server via a client browser's HTTP request to a webserver, which may send data back to the browser for rendering. These include $_GET,$_SERVER['DOCUMENT_ROOT'] (for relative web paths), and other such variables. You may need to convert these to use magic constants or otherwise work around your limitations.
I'm about to send you down a rabbit hole if you've never been to your command line, but you should SSH into your web server and try to execute your php file just like they said. You'll navigate to the directory with the file and run
php meats.php
Then, the command line will spit out any echos that you've got, or do whatever else your code does.

How to compare different files from 2 servers with rsync? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I got trouble with some hackers, they hacked into our website, so I cloned our server to a new one, and then reset the github on that server.
I heard about rsync can find out what is different about 2 servers. Is it possible for rsync ? Can I export that list of files to a text file?
Thanks your help, got hacked by use old version of wordpress >_< I was crazy with this from last couple days.
The comment by Marty is good - the rsync command as written will do a dry-run (-n) to show you what files were added/deleted/changed between the $TARGET and $SOURCE locations so you can then inspect or diff them to see if there is any malicious code.
Additionally, in the past when I've dealt with hacked WordPress installs, it is important to find the exploitation vector. Often times PHP shells get uploaded via some insecure script or plugin which gives the attacker a command based web shell to view files and run commands etc.
To find these files, the following command is helpful:
grep -E '(?:(shell_)?exec|system|eval)' /path/to/wordpress/* -R
This might yield something like:
wpte.php: eval($_POST['p1']);
Which in this case, wpte.php was a malicious PHP shell script that got uploaded to one of my client's servers that someone then used to run commands and upload more files. These scripts usually use one or more functions like eval or shell_exec to run commands input from the web shell.
Going from there, you can check the server access logs for hits to the malicious script and then further search the logs for the IP address(es) that accessed that script to potentially find how the uploaded the script or other hits resources they accessed.

Can PHP pages be run locally? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
Can PHP pages be run locally?
I am trying several demos on creating a contact form, at the moment I am trying this one:
http://www.html-form-guide.com/contact-form/php-email-contact-form.html
I have downloaded the source files and put my own email address in, but when I click submit I get directed to the PHP page. The form's action attribute is set to that PHP page, so I was wondering if it is because PHP is not able to run locally? If I want the form to submit and send to my email would I need to put the downloaded source pages online to make them work?
This is not the only tutorial I've used where this happens.
Sorry if this is a silly question - newbie web developer :).
Thanks.
PHP, in this context, is a server side language. It must be run by a webserver.
The webserver can be installed and run locally.
PHP needs to be executed server-side, which means you will need to set up a local webserver.
The best way to go would be taking a look at WAMP or MAMP or LAMP, depending on your operating system.
You need to be running a PHP server locally, and have the file "hosted" by the server (in the same folder, but usually /var/www/). There are a verity of free programs for this. I like WAMP ( http://sourceforge.net/projects/wampserver/)
You should simple install WAMP server. If you use Windows I recommend this one: http://www.easyphp.org/
When you install it you should copy php file to projects directory and then you can run in your browser http://localhost/projects/ to see your file and to execute it

Categories