Fopen failed no such file or directory kali linux

Why fopen with x mode gives me «failed to open stream: No such file or directory in»

I want to use mode x because as I can see from php.net that if the file exists it gives and error and also return false, and if not it creates it (also the directory’s). This is the script. It is located in www.ex.com/s/index.php

$urlParts = "/img/logo.png"; $fp = fopen( __DIR__ . $urlParts, "x" ); 

This should create logo.png (and also create the directory /img/) if it does not exist. but it is not working like this. Anyone can help? Thanks!

«and if not it creates it (also the directory’s [sic])» It doesn’t say that at all. It says «If the file does not exist, attempt to create it. This is equivalent to specifying O_EXCL|O_CREAT flags for the underlying open(2) system call.» No mention of directories.

1 Answer 1

It will not create the img directory in any case. If the directory does not exist, then it will always throw this warning.

Warning: fopen(/img/logo.png): failed to open stream: No such file or directory

If logo.png does not already exist, then it will create it without any warning. If logo.png already exists, then it will always throw this warning.

Warning: fopen(logo.png): failed to open stream: No such file or directory

fopen(«»,»x») is equivalent to specifying O_EXCL|O_CREAT flags for the underlying open(2) system call. Now let me help you understand why it happens.

In POSIX, The O_CREAT flag causes a file to be created if it doesn’t already exist. If you include the O_CREAT flag, you must also pass a third argument to open to designate the permissions. If you want to avoid writing over an existing file, use the combination O_CREAT | O_EXCL. This combination returns an error if the file already exists.

C program using POSIX

#include #include int open(const char *path, int oflag, . ); 

Conclusion: So we will use the «x» mode only when we want to avoid writing over an existing file.

Источник

Не могу ничего переместить и создать в /desktop

Всем здравствуй. Нужна помощь гуру, help?! Столкнулся с такой проблемой fopen failed : No such file or directory Could not create “/home/andr/Desktop/“ Права стоят чтение и запись. Desktop 51мг Архив GZIP x86_64 GNU/Linux Debian

Покажи целиком команду которую запускаешь и ls -l /home/andr/ | grep Desktop

kardapoltsev ★★★★ ( 21.07.21 01:52:11 MSK )
Последнее исправление: kardapoltsev 21.07.21 01:52:29 MSK (всего исправлений: 1)

cp /usr/share/wordlists/rockyou.txt.gz ./Desktop

cp: Невозможно создать обычный файл ‘/Desktop/‘: это не каталог

Читайте также:  Linux commands with pdf

cd: Нет такого файла или каталога : Desktop

ls -l /home/andr/ | grep Desktop

-rwxrwxr-x 1 andr adnr 53357329 июл 19 21:56 Desktop

Конечно нет. Есть «~/Desktop» или «$HOME/Desktop» или «/home/andr/Desktop». Одно из этих значений и подставляй в свои команды.

andytux ★★★★★ ( 21.07.21 08:40:43 MSK )
Последнее исправление: andytux 21.07.21 08:41:38 MSK (всего исправлений: 1)

Какое из сообщений здесь непонятно?

cp /usr/share/wordlists/rockyou.txt.gz ./Desktop

cp: Невозможно создать обычный файл ‘/Desktop/‘: это не каталог

Ты эту команду из какой директории запускаешь? Запись ./Desktop предполагает что ты должен находиться в домашней директории своего юзера. Иначе используй абсолютный путь /home/user/Desktop

-rwxrwxr-x 1 andr adnr 53357329 июл 19 21:56 Desktop

Эмм, это не каталог. Юзер и группа тоже различаются.

-rwxrwxr-x 1 andr andr 53357329 июл 19 21:56 Desktop

Это не каталог. Это файл. Что говорит потом команда ls -l

Что это за файл и откуда он там взялся, уже другой вопрос. Попробуй команду file Desktop

Для начала нам нужна база паролей для брута. В Кали уже есть база из 14 миллионов паролей и она называется «rockyou». Давайте её найдём, перенесём и распакуем на рабочий стол. Команда locate rockyou.txt.gz ищет файл «rockyou.txt.gz» по всей системе. Вот, на скриншоте видно, что путь до файла/usr/share/wordlists/rockyou.txt.gz.Теперь давайте перенесём файл на рабочий стол командой cp/usr/share/wordlists/rockyou.txt.gz./Desktop/. Осталось только распаковать архив командой gunzip -f /Desktop/rockyou.txt.gz.

Здесь прекрасно все: кали, инструкция из вк и ТС, не понимающий, что делает, но уже крутой хакер.

Источник

airodump-ng fopen failed: No such file or directory

The -w parameter of airodump-ng is for specifying a file prefix, not a folder.

The right command would be:

airodump-ng -c 11 --bssid 34:5B:34:7B:AC:66 -w /root/Desktop/capture_file mon2 

This will create a file on this path:

/root/Desktop/capture_file-01.csv 

Quote from the airodump-ng man page:

-w , —write Is the dump file prefix to use. If this option is not given, it will only show data on the screen.

2 Easy fixes to Arduino error: “.h: No such file or directory

How To Fix airodump-ng Error With wlan0mon Kali 2.0

How To Solve No Such Files Or Directories on Linux

SaveError ENOENT : no such file or directory

Kali Linux problem airodump-ng (fix 99,9%)

Everything123 Channel

I am just some random shitty coder trying to improve. Teach me daddy!

Updated on September 18, 2022

Comments

airodump-ng -c 11 --bssid 34:5B:34:7B:AC:66 -w /root/Desktop/ mon2 
fopen failed: No such file or directory Could not create "/root/Desktop/-01.csv" 

I can clearly see that is there is C language fopen error. Its trying create a csv file. I think mainly for maintaining the passowords it tests. I don’t know what is this csv files for just made a guess. I tried to create a simple .csv file with C Program using fopen and the csv file got created. So, there is not problem with C env is guess. I need help how do I fix this error?

Источник

«ecryptfs-mount-private» returns «fopen: No such file or directory»

So, as you can see, it shows such strange error: fopen: No such file or directory and, also, when running ecryptfs-mount-private without sudo — it fails. When mounting folder using ecrypts-recover-private and login password it mounts it in temporary folder like a charm.
Also, we’ve tried to ecryptfs-rewrap-password and it doesn’t work without sudo . So, using sudo ecryptfs-rewrap-password succeeded in rewrapping, but after reboot the same situation persists. All in all, what could this be; how to fix this auto mount encrypted home directory at login?

Читайте также:  Neighbours from hell linux

What was in syslog (or dmesg) right after it said «Check the system log for more information from libecryptfs»?

@Xen2050 What a shame. I’ve just ignored this message because of some fear that files might be gone. You’re right. That would be a right way to go. By the way, an author could add some message pointing that there’s no permissions etc.

Logfiles can get saved or rotated or deleted, but that shouldn’t happen right away. Also, many of the ecryptfs executables are bash scripts than can be examined and even ran one line at a time if you wanted, to see exactly what line’s failing, hopefully that might help too. A quick less $(which ecryptfs-mount-private) works

@Xen2050 Yes, log had this message. Checked with sudo grep «Failed to detect wrapped» -r «/var/log/» and an output had /var/log/auth.log.1:Jan 11 18:31:58 host login[3739]: Failed to detect wrapped passphrase version: Permission denied Thank you. It’s one of those times when log checking is definitely necessary and it would saved time.

I keep a terminal open with tail -f showing new log messages, just in case. zgrep might be handy in case the logs get zipped too. If my answer’s useful, do upvote it or even select it as correct (FYI selecting your own answer as correct does not award any reputation)

2 Answers 2

I set up an ecryptfs private folder, then removed the r & w permission from the wrapped-passphrase file to test. If you had checked the syslog right after seeing the message

Info: Check the system log for more information from libecryptfs 

You would have seen lines like this:

Jan 15 00:21:48 sys ecryptfs-insert-wrapped-passphrase-into-keyring: Failed to detect wrapped passphrase version: Permission denied
Jan 15 00:21:48 sys ecryptfs-insert-wrapped-passphrase-into-keyring: Error attempting to unwrap passphrase from file [/home/user/.ecryptfs/wrapped-passphrase]; rc = [-13]

Together those would be a pretty strong arrow pointing to check the permissions of the ~/.ecryptfs/wrapped-passphrase file. (No sudo or strace required)

All in all, just make sure you’re running ecryptfs-mount-private command as same user’s directory you’re trying to mount and wrapped-passphrase file has -rw——- or (600) permissions and same owner as encrypted directory.

In short, user’s file wrapped-passphrase had wrong permissions(should be -rw——- user user , were -rw——- root root ).

Ran ecryptfs-mount-private command(entered login password) using strace like:

strace -o /tmp/strace.log -e trace=file ecryptfs-mount-private 
user@host:~$ sudo strace -o /tmp/strace.log -e trace=file ecryptfs-mount-private [sudo] password for user: Enter your login passphrase: Inserted auth tok with sig [3ab5cd8e5f8c5acb] into the user session keyring fopen: No such file or directory user@host:~$ cat /tmp/strace.log execve("/usr/bin/ecryptfs-mount-private", ["ecryptfs-mount-private"], [/* 13 vars */]) = 0 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3 getcwd("/home/user", 4096) = 9 open("/usr/bin/ecryptfs-mount-private", O_RDONLY) = 3 --- SIGCHLD --- stat("/home/user/.ecryptfs/wrapping-independent", 0x7fff65e61c30) = -1 ENOENT (No such file or directory) open("/dev/null", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3 --- SIGCHLD --- stat("/home/user/.ecryptfs/wrapped-passphrase", ) = 0 stat("/home/user/.ecryptfs/Private.sig", ) = 0 --- SIGCHLD --- stat("/usr/local/sbin/stty", 0x7fff65e61c40) = -1 ENOENT (No such file or directory) stat("/usr/local/bin/stty", 0x7fff65e61c40) = -1 ENOENT (No such file or directory) stat("/usr/sbin/stty", 0x7fff65e61c40) = -1 ENOENT (No such file or directory) stat("/usr/bin/stty", 0x7fff65e61c40) = -1 ENOENT (No such file or directory) stat("/sbin/stty", 0x7fff65e61c40) = -1 ENOENT (No such file or directory) stat("/bin/stty", ) = 0 --- SIGCHLD --- --- SIGCHLD --- --- SIGCHLD --- --- SIGCHLD --- --- SIGCHLD --- --- SIGCHLD --- --- SIGCHLD --- +++ exited with 1 +++ 

So, we see that there’s not enough information. Ran the same command(entered login password), but with flag -f to trace child processes and using root’s rights:

sudo strace -o /tmp/strace2.log -f -e trace=file ecryptfs-mount-private` 

Part of contents of /tmp/strace2.log file:

. 3963 open("/root/.ecryptfsrc", O_RDONLY) = -1 ENOENT (No such file or directory) 3963 open("/home/user/.ecryptfs/wrapped-passphrase", O_RDONLY) = 3 . 3964 open("/etc/passwd", O_RDONLY|O_CLOEXEC) = 3 3964 open("/root/.ecryptfs/Private.mnt", O_RDONLY) = -1 ENOENT (No such file or directory) 3964 open("/dev/shm/ecryptfs-root-Private", O_RDWR|O_CREAT|O_NOFOLLOW, 0600) = 3 3964 open("/root/.ecryptfs/Private.sig", O_RDONLY) = -1 ENOENT (No such file or directory) 3964 +++ exited with 1 +++ 3954 --- SIGCHLD --- 3954 +++ exited with 1 +++ 

As we can see, it can’t find a file Private.sig of root; it looks like it should be ran by user who encrypted directory we are trying to recover instead of running in a particular directory.

Читайте также:  Ricoh sp 210 linux

All in all, I ran this command(entered login password) with user’s rights:

strace -o /tmp/strace3.log -f -e trace=file ecryptfs-mount-private` 

Part of contents of /tmp/strace3.log file:

. 4137 open("/lib/x86_64-linux-gnu/libnss_nis.so.2", O_RDONLY|O_CLOEXEC) = 3 4137 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) 4137 open("/lib/x86_64-linux-gnu/libnss_files.so.2", O_RDONLY|O_CLOEXEC) = 3 4137 open("/etc/passwd", O_RDONLY|O_CLOEXEC) = 3 4137 open("/home/user/.ecryptfsrc", O_RDONLY) = -1 ENOENT (No such file or directory) 4137 open("/home/user/.ecryptfs/wrapped-passphrase", O_RDONLY) = -1 EACCES (Permission denied) 4137 open("/etc/localtime", O_RDONLY|O_CLOEXEC) = 3 4137 +++ exited with 1 +++ 4112 --- SIGCHLD --- . 

As we can see now, an ecryptfs-mount-private utility can’t access user’s wrapped-passphrase file which resulted in Permission denied message.

Checked /home/user/.ecryptfs/wrapped-passphrase file’s permissions and they were:

Changed owner of this file via sudo chown user:user /home/user/.ecryptfs/wrapped-passphrase to user and reran above ( ecryptfs-mount-private ) command without strace(entered login password) which resulted in success message:

INFO: Your private directory has been mounted. INFO: To see this change in your current shell: cd: /home/user 

Источник

Оцените статью
Adblock
detector